0 votes

Hi guys.
I'm facing a issue that is frutating me as I cannot find the trick.

I'm trying to create an explosion effect when a magic bolt impacts something. The approaching is similar to the TPS Demo Shooter, but I use a Area node as root.

The bolt is done following this YT tuto:
https://www.youtube.com/watch?v=DkJ2jYl-ESw&list=WL&index=8&t=279s

My problem is that in the very moment one bolt impacts something, all next bolts are instanced in last status of animation, or this seems. I've tried to stop animation before queue_free(), set all parameters as they should be in _ready() but nothing seems to work.

I'm quite sure is a stupid detail but honestly, I'm quite blocked.

My ball scene:
https://ibb.co/VvXLHPW

A link to an small video:
https://drive.google.com/file/d/1Y8PCA9a5KSTw89zE4PnhODZGzqDLO8_h/view?usp=sharing

Involved code:

func _on_bola_body_entered(body):
if ball_ha_dado == false:
    if body.has_method("dolor"):
        #paso el daƱo, la posicion de la colision
        body.dolor(DAMAGE, global_transform)
col.disabled =true
bolt_anim.play("explotar")
ball_ha_dado = true

Thank you.

Godot version 3.3.2
in Engine by (28 points)

is the code indented properly? ball_ha_dado = true seems to be outside the last if check

Hi, Vnmk8.

It's outside, but on purpose. The if stament is just to ensure behind enemies are not being affected due to time gaps until queue_free().

1 Answer

0 votes

I haven't looked at the project, but I'm assuming:

bolt_anim.play("explotar")

^ Isn't in the bolt script itself, so it's not really being uniquely instanced. It looks like it may be getting referenced. So when it goes to explode, all the bolts explode. You may need to make sure this animation player is in the bolt itself, where it can be uniquely instanced with each bolt.

by (341 points)

The complete scene is called "bola", instanced each time player "shoot", which has the collision and 2 particle nodes, one is "bolt", and the other "chispas". The AnimationPlayer is child of "bola", not from bolt to use the queue_free() of the whole scene.

I'll try this afternoon to move animationplayer to bolt node and more playarounds.

It would be good to see the script for the variable bolt_anim.

Check and make sure that what you're calling is the instanced version of the AnimationPlayer and not just the original scene in your 'FileSystem'.

So it should look something like:

func _on_bola_body_entered(body):
    if ball_ha_dado == false:
        if body.has_method("dolor"):
            body.dolor(DAMAGE, global_transform)
        col.set_deferred("disabled", true)  #Use set_deferred for disabling collision
        body.find_node("AnimationPlayer").play("explotar") #Using the "body" argument to grab which instance's AnimationPlayer we want to use.
        ball_ha_dado = true
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.