AnimationPlayer - making multiple animations will override previous ones

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By mj4life92

Hi, I am following some tutorials on youtube on how to create multiple animations using AnimationPlayer node. In the tutorial (https://www.youtube.com/watch?v=ATfE4k6EP9U&ab_channel=TheDevDoc) they made 2 animations. I tried the same thing, but the problem I am facing is that the 2nd animation will override the first one. So basically in both my “walk” and “attack” animations, my enemy will attack.

Here is what I have in my enemy scene:

Sprite
CollisionShape2d
AnimationPlayer

Here are my steps:

  1. Click on the ‘Animation’ button and hit ‘NEW’

  2. I will name this ‘walk’ and hit ‘ok’

  3. In my tree, I click on the Sprite → then I drag and drop my ‘walk.png’ file containing 8 frames of animation into the Sprite Texture

  4. In the AnimationPlayer, I click on ‘Add Track’ → Property Track → “Pick the node that will be animated” , here I chose Sprite → then select the ‘frame’ property

  5. I click on the Sprite again and under the ‘Animation’ property I select the Hframes (in my case 8 since there are 8 frames of animation in my png) → then I select Frame to be 0 → then I click on the key next to it 8 times to add all frames

  6. I play the selected animation (the only one at the moment) and everything looks okay and I save

  7. I then repeat from step 1), I create a new animation, go on the sprite again and add another one called “attack.png” which I add to my sprite and then add the keys.

  8. After this is done I know have 2 animations, 1 for walk and 1 for attack, but when I switch between them in AnimationPlayer by using the dropdown arrow, both of the animations will have the key frames set from the latest steps performed ( from attack). Now both walk and attack have the attack keyframes set…

I don’t get what I’m doing wrong…i just want to use multiple animations. I am also a newb btw…

:bust_in_silhouette: Reply From: DarthPlayer

This 6 minute video give the complete answer to your question, please spread this around for others having the same problem.

thanks! I really thought it would solve this issue, but I followed this video and the animations are still being overriden by the frames used in the last sprite texture.

Does this have anything to do with the fact that the number of horizontal frames varies between animations? For ‘walk’ I use 8 frames but for ‘attack’ there are 5 frames. I do change these in the Sprite Animation properties for each animation I create using AnimationPlayer. Should I try adding Hframes as a track in the AnimationPlayer?

mj4life92 | 2022-12-16 16:00

I just followed the video guide bit by bit and made sure I got everything correctly and it worked for me.

Try deleting everything from the player node and start over. Make sure the V frames and H Frames are correct. You’ll know they are correct if you only see one frame per frame click. Then follow the guide

DarthPlayer | 2022-12-16 16:13

Based on the video I think I narrowed this down a bit more, here is what we have so far:
I tried this using 2 animations which have the exact same number of frames, 5.

  1. AnimationPlayer → Animation → New → created a new animation called ‘dead’
  2. Sprite → drag and drop the “Dead.png” into “Texture” field
  3. Click on the little key next to “Texture” field to add to the AnimationPlayer track , clicked on Create
  4. HFrames → 5
  5. Added HFrames to track by using the key (I tried with and without this)
  6. Frame → 0
  7. Clicked on the little key next to Frame which created the ‘frame’ property in AnimationPlayer
  8. Frame 0 was added at 0, I manually clicked on 0.1 on the track time scale
  9. In the Sprite, clicked the little key to add Frame 1
  10. Added Frame 2, 3, 4
  11. Changed animation length to 0.5
  12. Saved

2nd Animation

  1. Clicked on Animation button in AnimationPlayer
    14, New → created “attack” animation

  2. Clicked on Sprite

  3. Drag and drop the “attack.png” to the Sprite Texture field and saved

  4. At this point even, if I switch from “attack” to “dead” animation in the AnimationPlayer, both the attack and dead animations will have the dead animation frames instead of being different…

mj4life92 | 2022-12-16 16:28

thanks for your help! It turns out I was very very high and was doing things in a different order. It works now that I am sober.

mj4life92 | 2022-12-17 11:48