godotengine / godotengine/godot
Animation Freezes When Played for First Time & AnimationTree Transition Does Not Work When Animation is Looping
- Dominant language
- C++
- Stars
- 117k
- Forks
- 26.8k
- PR merge metrics
- PR metrics pending
Description
### Tested versions
Tested in Godot 4.2 stable and v4.3.rc3.mono.official [03afb92ef]
### System information
Windows 11, Gpu RX 6600, Cpu 10400, Godot v4.3.rc3.mono.official [03afb92ef]
### Issue description
- Animations do not play if looping is enabled for the rest animations
- There is a freeze that occurs just after playing the reload animation for the first time (more info on this below)
https://github.com/user-attachments/assets/d6ce6856-dd4c-42ce-80bd-30f96c16e4b7
### Steps to reproduce
1. Open up the attached MRP.
There will be 2 AnimationPlayer nodes. Currently the "arms_rest" and "assault_rifle_rest" are not set to be looping. We will get back to this later.
2. Play the game with F5.
Immediately press R to play the reload animation. Part of the animation will freeze for the first time playing but will not freeze after that. You should see the reload animation play on repeat.
Some observations about the freeze.
- Only the weapon animation freezes, the entire game did not freeze
- If you wait 10 seconds before playing the weapon reload animation then there will be no freezing to begin with
- The freeze happens every time the game starts up
This warning will appear in the console.
```
W 0:00:04:0825 _transition_to_next_recursive: AnimationNodeStateMachinePlayback: parameters/playback aborts the transition by detecting one or more looped transitions in the same frame to prevent to infinity loop. You may need to check the transition settings.
scene/animation/animation_node_state_machine.cpp:918 @ _transition_to_next_recursive()
```
3. Close the game and set the "arms_rest" and "assault_rifle_rest" animations to be looping by clicking the looping icon in each AnimationPlayer node.

4. Play the game again with F5
Press R to play the reload animation and notice how the animations will not play at all. The same warning that appeared in console will appear again.
### Minimal reproduction project (MRP)
MRP is 27 mb and GitHub upload limit is 25 mb so MRP was uploaded to MediaFire.
https://www.mediafire.com/file/3e7p575esehewe1/MRP_AnimationTest.zip/file
Contributor guide
Research direction
Start by reproducing the issue with the linked MRP, testing the reload animation both before and after enabling looping. Then inspect scene/animation/animation_node_state_machine.cpp around _transition_to_next_recursive() at line 918. Done means the first playback no longer freezes, looping rest animations transition correctly, and the warning is absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100