On setting _process to"false"
to trigger an explosion(AnimatedSprite) at the position where a bullet(Area2d) enters an enemy(Rigidbody), the explosion animation doesn't take place at the collision point ,but way beyond
. However,the bullet sprite visibility is set to false ,as soon as the collision is detected.
The explosion sprite inherits its position from the bullet
.How to stop _process from triggering once collision has taken place?
#weapon.gd
extends Area2D
func _process(delta):
# if is_processing(): # still _process triggers after collision
# position += velocity * delta
position += velocity * delta
#bullet.gd
extends weapon.gd
func _on_bullet_body_entered(body):
set_process(false)
explosion.position = self.position
set_deferred("monitoring",false)
explosion.visible = true
explosion.playing = true
bulletsprite.visible = false