godotengine / godotengine/godot

AnimationMixer cannot merges/handles duplicated property tracks in the same animation

Open
#113,136 1 comment 0 reactions 0 assignees View on GitHub
discussion topic:animation topic:editor
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

Reproducible in 4.5.stable
Different behavior in 3.6

### System information

Godot v4.5.stable.mono - Windows 11 (build 22621) - Multi-window, 1 monitor - OpenGL 3 (Compatibility) - NVIDIA GeForce RTX 4060 Laptop GPU (NVIDIA; 32.0.15.8157) - AMD Ryzen 9 7940HS w/ Radeon 780M Graphics (16 threads) - 63.21 GiB memory

### Issue description

`AnimationPlayer` does not handle properties when a track is duplicated.

Image

The following example tries to move a sprite from (0, 0), to (250, 0), twice, over two tracks, with the second starting as the first completes.

- Track 1 `Position`:
- - 0.0s (0, 0)
- - 0.5s (250, 0)
- Track 2 `Position`:
- - 0.5s (0, 0)
- - 1.0s (250, 0)

The expected behavior is for the sprite to move from (0, 0) to (250, 0) over 0.5 secs, then snap back to (0, 0) and repeat. However the sprite ends up with the movements combined (500, 0).

In Godot 3.x, this method was supported, so long as the property changes did not overlap.

It's not clear to me whether this is an intentional break in 4.x, and duplicate tracks are no longer supported, or whether this is a bug. The movement to (500, 0) seems unexpected in either case. If its intended for this method to be no longer supported, then duplicate tracks should be disallowed, and/or warnings logged, and docs should be updated accordingly.

For further context, this method was being used in our project to "snap" something back to its original position and animate again elsewhere, reusing the object multiple times in the same animation player. This is achievable in 4.x by putting the "snap" position on the same track 0.001s after the end position instead, but this is particularly horrible to then manage as the values are on top of each other in the UI. Splitting tracks made it much easier to manage.

### Steps to reproduce

1. Create an animation with a `position` track to move a Sprite2D.
2. Set the key-frames at (0, 0), and (250, 0) at 0s at 0.5secs respectively.
3. Create another track for the same property (e.g. by copying the track).
4. On the second track, set the key-frames at (0, 0), and (250, 0) at 0.5s at 1.0secs respectively.

Run the animation and notice the sprite never return to (0, 0), and and up at (500, 0).

### Minimal reproduction project (MRP)

[animation-tracks.zip](https://github.com/user-attachments/files/23734909/animation-tracks.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached animation-tracks.zip minimal reproduction and the AnimationPlayer/AnimationMixer handling of duplicated property tracks. Compare the behavior with Godot 3.6 and determine whether non-overlapping duplicate tracks should remain supported or be rejected. Done means the intended behavior is implemented and covered by a regression test, or duplicate tracks are clearly rejected and documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, godot
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.