0 votes

I have a project where I animate the color (using modulate) of a sprite.

The animation works as I intended but it affects ALL of the instances and not just the selected instance.

I can't seem to narrow down where I went wrong, but I suspect it has something to do with the way I animated my sprite as I read somewhere that a person had a similar problem and it was because he animated the image rather than the sprite.

I'm really not sure but I tried doing it several different ways. I'm a bit lost on this as it's all new to me so I would love to hear any suggestions.

Animation Player setup

Godot version 3.3.2
in Engine by (25 points)

1 Answer

+1 vote
Best answer

It looks like you're using a singleton called "GlobalSignals" to trigger the animation, which I am going to assume is, well... global. The animation looks fine, you just need to ensure only the appropriate ships react to being hit.

by (1,259 points)
selected by


You're right. I'm using a global signal to trigger the animation. So, I guess I can't do that. The problem is I'm not sure how to trigger the animation then.

The enemy is an instanced child so it doesn't actually exist in the main scene which means I can't reference the animation from there which is why I was using a singleton.

How can I reference the AnimationPlayer that I created in the Enemy scene?

I tried emit_signal, but it doesn't work. Sorry for the noob questions, but I'm still a noob!


How do you detect whether the ship is being hit? Is it like, a collision with a bullet? The idea is to connect said event with the action of being hit. For instance:

func _ready():
    $Area.connect("area_entered", self, _on_collision)

func _on_collision(other):
    if other is Bullet:

It all really depends on how the game works.

Oh, I see. Maybe that's why I'm having problems. I'm making a typing game and once the letters are typed, I queue_free the enemy ship. However, I wanted to add a bit of animation to it as well whenever a letter is typed as well as making an animation for destroying the enemy ship.

However, the enemy is not in the main scene but instanced so I don't have a path to reference.

No bullets are used, no area is being entered.

I can queue_free the instance of the ship in the main scene, but I'm having problems doing any kind of animation on it without using a GlobalSignal. But as you know, by doing that I affect all the ships on the screen.

If you want to look at the code it's zipped here:


Ok I looked over the code, there were a bunch of things I needed to change in order to get it working. First, there's no point in adding any bullet object, that was just a random example I mentioned since I had no idea this were a typing game. Then, I had to set the animation to modify self_modulate for the *sprite* instead of the scene root. Then, I just removed the signal altogether and simply added enemy.animate_ship_is_hit() right below $AudioLaser.play() in find_new_active_enemy and active_enemy.animate_ship_is_hit() in _unhandled_input (since I assume you want the animation to play in both cases). Since the direction of the action flow is parent -> child, there's really no need for signals, which are more useful in a child -> parent paradigm.

Thanks for looking it over! You're so amazing!!!

I didn't really want to use signals, but I wasn't able to figure out how to connect them until you told me just now. I'm making some other programs as well so this will definitely help me understand the connections better.

Actually, I put the bullet object in there because I was thinking about shooting a bullet towards a ship after each key is typed, but I was having problems trying to figure out how to get the bullet to target each ship properly so I left it for a later time and decided to just have the ship turn red instead.

I was trying to use self-modulate for the sprite instead of the scene root, but it nothing seemed to work for me. I think I'm just too new at this to do it properly. Anyway, I finally did get that part working today, but I'm really not sure how I did that as I kept trying over and over.

The part I was really struggling with was the last part you were talking about. I think I now understand how it's all connected.

I am also going to add in a death explosion at the end as well, so thanks for that!! I'm so excited that it's working better now. I still have a LOOONG way to go, but this is one step closer to understanding Godot.

Happy to hear that :) Have fun!

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.