AnimationPlayer Overrides Global Transform

Godot v4.3 Stable – 77dcf97d8

Not a question, but noticed some interesting behavior with AnimationPlayer and wanted to know if this is intended…

// General Behavior with TSCN
Generally, there is a LEVEL TSCN and an OBJECT TSCN. The behavior is the interaction of the transformation properties regarding nested TSCNs.

When placing the object in the level, the transform information is independent of the the object transform information.

[Example]
Static3D is at location 0,0,0 within the object
Static3D is at location 6,6,6 within the level.

Running the game, the Static3D will be at location 6,6,6 in final render (0,0,0 object + 6,6,6 level).
Changing Static3D object to 1,1,1 and running game: the object will result in 7,7,7 final render (1,1,1 object + 6,6,6 world).

This is the expected and observed behavior.

// AnimationPlayer
If you take the same object tscn and add an AnimationPlayer, add a simple “slide” animation. It overrides the final render (or at least the world transform data).

Add AnimationPlayer
New Animation: Slide
Key0: Static3D/Transform/Position: 0,0,0
Key1: Static3D/Transform/Position: 0,7,0 (mimic a door sliding up)
Script: func action_door(): $AnimationPlayer.play(“slide”)

[Results]
The Static3D shows CORRECTLY in EDITING VIEWPORT when viewing the Level TSCN.
Rendering the Game: Object Snaps to 0,0,0 regardless of Level Transform Data.***

Note***: This only affects the values that are going to change within the AnimationPlayer Keys – in this instance, the _.position.y is the only value changing with the animation and thus X,Z are unaffected when the game starts running. When demo’ing this in levels, the doors would be “floating” in air or in the ground depending on the layouts.

// Workaround
I created a Node3D Master Node to parent all the objects to act as the world anchor and let the AnimationPlayer Manipulate the Static3D within the Anchor Object Space.

//
So either this is expected or I found a weird bug. :3

For this work, try to use tween, you can learn this by any videos or docs.

I got it working with the world_anchor trick… I was just wondering if it was a bug cause the behavior differs from most objects.

I can’t ACTUALLY find Tween in Godot… I’ve some of the stuff about it in Online Guides / YouTube videos, but when I search in the Node Trees, I don’t get the same results as some folks. #strange

1 Like

You can’t find this?

I’ve seen the code and it works, but I’ve seen people pull it up in the Node UX before.