0 votes

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.emitting = true

    if explosion.emitting == false:


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?

Godot version 3.3.2
in Engine by (19 points)

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()).

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.