Olan2go

Somehow the exited function against explosion call


extends Mob

onready var shock_area := $ShockArea

func _ready():
    _animation_player.connect("animation_finished", self, "_on_AnimationPlayer_animation_finished")
    shock_area.connect("body_entered", self, "_on_ShockArea_body_entered")
    
func _on_AnimationPlayer_animation_finished(anim_name: String) -> void:
    if anim_name == "will_explode":
        _disable()
        _animation_player.play("explode")
        _die_sound.play() #I skip queue_free() here cause _die_sound will call
    elif anim_name == "RESET":
        _animation_player.play("hover")  

func _on_ShockArea_body_entered(body : PhysicsBody2D) -> void:
   if body == self: return if body.has_method("take_damage"): body.take_damage(damage)

func _on_AttackArea_body_entered(body: Robot) -> void:
    _sprite_alert.visible = true
    _animation_player.play("will_explode")
    
func _on_AttackArea_body_exited(_body: Robot) -> void:
    _sprite_alert.visible = false
    _animation_player.play("RESET")

(I've noticed the solution project's code calls disconnect function in body entered function, but that won't fulfill the requirement of RESET bomb, we can see code can reset bomb in the video, but the bomb just became unexploded bomb with sound)

  • Nathan Lovato replied

    Thanks for sharing, I see that yeah in the finished project we don´t have the reset feature. I'm logging this task for a future release.