What is the intended way to transition from any procedurally generated 3d position and rotation to the first frame of a predefined animation made in AnimationPlayer?
A player controls a virtual arm that flops all over the screen, but when it is time to interact with a complicated object, like a door or a dial pad, I’d like to just play a predefined animation. Problem is - due to the unpredictable nature of aforementioned procedural animation, when the player commences the interaction, the arm can be in any position and rotation, and when I play the animation it snaps to the first frame.
Is there any way to get the AnimationPlayer to lerp from the current node3d position/rotation to the pose in the beginning of the animation before playing it?
Still haven’t found any information on the correct way to do it, but for future readers there is a way to modify any animation data at runtime via scripts. It’s error prone and probably can cause all sorts of issues, but here is an example:
var animation = GuyAnimationPlayer.get_animation("door_open")
animation.track_set_key_value(0, 0, RHand.basis.get_rotation_quaternion())
animation.track_set_key_value(1, 0, RHand.position)
To make use of this trick I’ve added a new dummy keyframe at the start of the animation. The contents of this keyframe are then always overriden in script before playing the animation.
I suspect that if this approach is used for animations shared across multiple nodes, there will be unpredictable results, but in my case there is only one object being animated with this animation so I kinda get away with it. Still, if anyone knows a better way, please share