Animation that changes position

  1. What do you want to achieve? Animation like jumping a window but when it finishes it will put the character in the same position that the anim ends.

  2. What is the issue? Don’t know how to achieve that anim.

As said in first point: imagine i need an animation that the character jumps through the window (using animation frame per frame). Everyone can do that but this is only the anim e normally animation after ending it will return to the default position it starts.
How to place/move the character to the exact position to the last frame position of this animation?

1 Like

humanoid.animator:LoadAnimatio(yourAnimation)

i think you didn’t understand.

2 Likes

To load animation, Use
local Animation = Humanoid:LoadAnimation(animationobject)
Animation:Play()

To set players position at the end of the animation, try using

task.wait(Animation.Length)

Character:PivotTo(Character.PrimaryPart.CFrame)

or

Character:MoveTo(Character.PrimaryPart.Position)

then you instantly stop the animation with Animation:Stop(0)

I probably didnt :sob: im not that good at helping people

I tried it here. It was a nice try but i noticed that the position of primarypart of the character stays the same even in the anim you are moving him around

Just FYI, what you’re asking for here is called root motion; the ability for an animation track to animate the physics simulation’s position of your character in the world (represented in Roblox avatars by the HumanoidRootPart).

The proper way to do this is to take the root motion encoded in the animation and translate to velocity of the root part, so that the physics simulation of your character matches what the animation prescribes.

The hack way, is to let your animation play, and when it hits the end of the timeline, CFrame the root part to the final location, to exactly cancel out the jump in position. Don’t try to sync this with a wait function though, bind to the actual animation track ended event.

The hack option can be made to look correct, but since it basically does a mini teleport of the character root, it will be possible in some cases to use the animation to do things like no-clip through walls. The lack of continuous physics simulation is the downside of this approach. The upside is that it’s way easier to implement than the first method, which requires translating a root motion track (e.g. on a proxy Bone) to the correct velocities or forces needed to make the HRP follow the animated path.

1 Like

And how to get the frame position in live anim playing?

i think this is what you’re looking for

3 Likes

When a non-looping animation finished playing, it fires the AnimationTrack Ended event, you can see how to use it here:

The offset in character position between the start and end of your animation is something you know ahead of time, you can just measure it right from your animation in the editor. It gets a little more complicated than this if you’re blending more than one animation, but I’m assuming right now that you’re just playing 1 (or at least only 1 that has root motion). There’s a way to get the actual offset of a blended animation too, you can read the LowerTorso “Root” Motor6D Transform property in the OnStepped event, but you probably don’t need to do this unless you’re blending animations.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.