![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Code Ripple |
Hello. I am new to the godot engine and I am trying to set the particles to emit when the player enters the body of the enemy. This is my code:
func _on_Area2D_body_entered(body):
Health -= 20
if body.name == "Player" or body.name == "PlayerCollider" or body.name == "PlayerArena":
explosion.set_position(body.position)
explosion.emitting = true
explosion.add_child(explosion)
print("Particle")
if explosion.emitting == false:
explosion.queue_free()
body.queue_free()
queue_free()
And the part where I loaded the ‘explosion’ scene is:
var explosion = load("res://Particles.tscn").instance()
What am I doing wrong and why is the particle not emitting when the player goes into the enemy?
We’re going to have to see more of the setup here. From what I can tell, the scene for the particles/explosion should be preloaded so as to save on performance. When it’s time, the explosion should be instanced, then added as a child, then moved into place, then setup (i.e. explosion.emitting = true
), and finally animated. Once the explosion animation is finished, the scene should be removed (i.e. use queue_free()
).
Ertain | 2021-08-15 17:48