Hello Members! I played with Godot for some time, trying to make some simple funny games for my family and my ambition got me to a point where I can not find a solution. In general, each game is nothing sophisticated. Now I am working on animated baloons floating mid-air and the task is to "pop the baloon". The whole user interaction is recorded from the computer camera and "caught" by Godot. The basic animation is "outsourced" from the AnimatedSprite. Additionally, I prepared two AnimationPlayer nodes of which one shows the interaction (baloon changes color through modulation) and the second fades the baloon out when it is hit enough times. My question is - if I have a frame-by-frame animation of the baloon exploding, how can I add it to Godot and use it instead of the fadeout in the AnimationPlayer? All hints are welcome!
How can I add an additional animation?
Not sure if it would work, but you might be able to have the fade animation in the AnimationPlayer tell the AniamtedSprite that contains the balloon popping animation to play through a call method track.
You can make a call method track in an AnimationPlayer by opening the animation tab at the bottom of the Godot editor and then pressing the plus button in the top left of the panel. I believe the call method track is green. When you create the track it should have you point it to a node, which you'll want to point to the AnimatedSprite. Then once that is done, if you right click in the track at the keyframe position you want, you should be able to add a key and call the play
function in the AnimatedSprite so it can play the balloon popping animation.
Hello!
Thank You for the response! I thought it is some kind of a hopeless case.
I tried as You suggested. I attached an image to be sure if I am doing things correctly.
Currently, my setup is the following:
You can see here all the nodes. The hit_- and die_animationPlayer respond to whatever happens when the baloon interaction is registered in the viewport (modulation when interaction occurs and well, death whenever it actually runs out of health). The AnimatedSprite_Death holds the animation for the actual "pop" of the ballon which is then, according to Your advice being called, by the 'baloon death' player containing the propper animation with the call method. Could You review please is it correct here? I still can not make it work somehow.
@TheHeartless said: Hello! Thank You for the response! I thought it is some kind of a hopeless case. I tried as You suggested. I attached an image to be sure if I am doing things correctly. Currently, my setup is the following:
You can see here all the nodes. The hit_- and die_animationPlayer respond to whatever happens when the baloon interaction is registered in the viewport (modulation when interaction occurs and well, death whenever it actually runs out of health). The AnimatedSprite_Death holds the animation for the actual "pop" of the ballon which is then, according to Your advice being called, by the 'baloon death' player containing the propper animation with the call method. Could You review please is it correct here? I still can not make it work somehow.
Looks correct to me, at least based on the setup. How is the animation not working?
Looking at the setup, are you making the AnimatedSprite_Death node visible before calling the baloon_death
animation?
@TwistedTwigleg said: Looks correct to me, at least based on the setup. How is the animation not working?
Looking at the setup, are you making the AnimatedSprite_Death node visible before calling the
baloon_death
animation?
I turn on the animation which is not visible on my screenshot. However, when run, both animations are playing - namely the basic floating baloon animation together with the baloon_death animation. I sense there is some solution to that, though I can not get there :/
Can you share the code you are using for changing the animations? Maybe something there is causing the issue.
- Edited
Basically the part esponsible for the animation is below:
func hit():
health = health - hit_damage
if health > 0:
print("health > 0: " + str(health))
$hit_AnimationPlayer.play("hit_Animation")
else:
$baloon_death.play("baloon_death")
$CollisionShape2D.set_deferred("disabled", true)
print("health <= 0: " + str(health))
pass
Currently, the baloon popping animation (baloon_death) plays along the initial animation of the baloon hanging in the air.
I do not see anything in the code that would be causing the issue. The balloon death animation isn't set to auto play, right? I doubt it is, but it never hurts to check just in case.
@TwistedTwigleg said: I do not see anything in the code that would be causing the issue. The balloon death animation isn't set to auto play, right? I doubt it is, but it never hurts to check just in case.
I don't think so? The only playing options are set in the sprites. I noticed a funny thing though. In the hit- and diaAnimationPlayer I can view the animation in the panel below., however, the baloon_death player does nothing after playing the animation. I am not sure if it is how it supposed to be.
- Edited
i would use a single animation player for all this
func hit():
health = health - hit_damage
$hit_AnimationPlayer.play("hit_Animation")
func _on_hitAnimationPlayer_animation_finished(anim_name):
if anim.name == "hit_Animation" and health <= 0:
$CollisionShape2D.set_deferred("disabled", true)
$AnimatedSprite.playing = false
$AnimatedSprite.hide() #maybe hide this?
$AnimatedSprite_dead.playing = true
$baloon_death.play("baloon_death")
if anim.name == ""baloon_death":
queue_free()
@Zelta said: i would use a single animation player for all this
func hit(): health = health - hit_damage $hit_AnimationPlayer.play("hit_Animation")
func _on_hitAnimationPlayer_animation_finished(anim_name): if anim.name == "hit_Animation" and health <= 0: $CollisionShape2D.set_deferred("disabled", true) $AnimatedSprite.playing = false $AnimatedSprite.hide() #maybe hide this? $AnimatedSprite_dead.playing = true $baloon_death.play("baloon_death")
if anim.name == ""baloon_death": queue_free()
Thank You for the response Zelta! I am not sure if I can make it work like that. The game screen does not load here.
The issue is that the balloon death animation plays with the idle/rising animation, right? If so, it sounds like it is being triggered instantly when the node is spawned, if I had to guess.
As long as the auto start icon is not blue/enabled on the AnimationPlayer, then it shouldn't play at start automatically:
- Edited
@TwistedTwigleg said: The issue is that the balloon death animation plays with the idle/rising animation, right? If so, it sounds like it is being triggered instantly when the node is spawned, if I had to guess.
As long as the auto start icon is not blue/enabled on the AnimationPlayer, then it shouldn't play at start automatically:
I checked and I had no option like that selected.
@Zelta , and especially @TwistedTwigleg , You are helping me a lot here, thank You! I think I must be doing something seriously wrong as this seems to be some sort of basic functionality on which I can not wrap my head around :/ I will work on it more, Now I have placed all animations into one sprite. I thought of assigning the "death" player to try to fetch the particular death sequence (sounds seriously cool!) from the animation sprite. But it seems I can't point to the animation within the sprite from the GUI. Maybe I should think of a code-like solution, i.e. it might be easier to access from the code side?
where is the gui? could u paste the code or some pic?
Here is just the screen from the timeline:
I am attempting to call this animation through the previous code:
func hit():
health = health - hit_damage
if health > 0:
print("health > 0: " + str(health))
$hit_AnimationPlayer.play("hit_Animation")
else:
$baloon_death.play("baloon_death")
$CollisionShape2D.set_deferred("disabled", true)
print("health <= 0: " + str(health))
pass
However the animation track is not visible, not it can be played from that particular player.
Looking at the picture of the timeline, do you have a keyframe that is calling the function? There should be a small diamond on the animation time position if there is a keyframe. For example, if you hover your mouse over the "Functions" row and right click, you should have an option like "add keyframe". Then you can add a key frame to call a function from the animation player.
Though, I don't think it will help with the issue where the animation is being played at start...
@TwistedTwigleg said: Looking at the picture of the timeline, do you have a keyframe that is calling the function? There should be a small diamond on the animation time position if there is a keyframe. For example, if you hover your mouse over the "Functions" row and right click, you should have an option like "add keyframe". Then you can add a key frame to call a function from the animation player.
Though, I don't think it will help with the issue where the animation is being played at start...
Whenever I try to add a keyframe, it prints "Track path is invalid, so can't add a method key". The animation player points to the sprite and the sprite contains the animation "4_baloon_death". Is there another way to point to the animation then?
IIRC how function tracks work, the functions track should get a keyframe that triggers a function in a script that then in turn sets your animation to play.
I don't know if there is another way to set a function from an animation player. You can call the function normally through code right when you change animations though.
Ok, thank You. I will give up on the idea then. For now, it is clearly above my level.