Fix Hammer Bro crash (#669)

This commit is contained in:
John Cooper McDonald
2025-10-25 11:33:45 -05:00
committed by GitHub
parent 0eb791a697
commit 51e1907b01

View File

@@ -20,7 +20,7 @@ func _ready() -> void:
func _process(delta: float) -> void: func _process(delta: float) -> void:
target_player = get_tree().get_first_node_in_group("Players") target_player = get_tree().get_first_node_in_group("Players")
direction = sign(target_player.global_position.x - global_position.x) direction = sign(target_player.global_position.x - global_position.x)
$Sprite.scale.x = direction $MovementJoint/Sprite.scale.x = -direction
if $TrackJoint.is_attached: $MovementAnimations.play("RESET") if $TrackJoint.is_attached: $MovementAnimations.play("RESET")
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
@@ -67,16 +67,16 @@ func do_hammer_throw() -> void:
$HammerTimer.start(randf_range(2, 5)) $HammerTimer.start(randf_range(2, 5))
func throw_hammer() -> void: func throw_hammer() -> void:
$Sprite/Hammer.show() $MovementJoint/Sprite/Hammer.show()
$Sprite.play("Hammer") $MovementJoint/Sprite.play("Hammer")
await get_tree().create_timer(0.5, false).timeout await get_tree().create_timer(0.5, false).timeout
spawn_hammer() spawn_hammer()
$Sprite.play("Idle") $MovementJoint/Sprite.play("Idle")
$Sprite/Hammer.hide() $MovementJoint/Sprite/Hammer.hide()
func spawn_hammer() -> void: func spawn_hammer() -> void:
var node = HAMMER.instantiate() var node = HAMMER.instantiate()
node.global_position = $Sprite/Hammer.global_position node.global_position = $MovementJoint/Sprite/Hammer.global_position
node.direction = direction node.direction = direction
if $TrackJoint.is_attached: if $TrackJoint.is_attached:
get_parent().owner.add_sibling(node) get_parent().owner.add_sibling(node)