How to make character remain in pose after animation finishes playing

Hello, this is my first time scripting with animations, so I am pretty ignorant toward it. So I made an animation that makes the player make a pose; however, after the animation finishes playing, it automatically reverts to the standard idle position. How do I make it so that it stays in that pose and stop other animations from playing?

25 Likes

I haven’t tested this, but you could listen to AnimationTrack’s .Stopped event. Once that event gets fired, you can set the TimePosition property to the end of the animation and then set the speed to 0 (via :AdjustSpeed()).

animationTrack.Stopped:Connect(function()
    animationTrack:AdjustSpeed(0)
    animationTrack.TimePosition = animationTrack.Length
end)
30 Likes

Another solution is to make your animation loop (has to be set in the animation editor before export).

That is, if the animation entirely consists of the pose and doesn’t have the transition.

4 Likes

Another solution that works is if you extend the animation a bit and just hold the same pose past a named keyframe, then you just freeze the animation.

4 Likes

I believe when the animation has stopped it is too late for this.

I usually name the second last (not the last) keyframe to ‘Pause’ then listen for this keyframe in a KeyframeReached connection.

Ie.

animationTrack.KeyframeReached:connect(function(keyframeName)
    if keyframeName == "Pause" then
        animationTrack:AdjustSpeed(0)
    end
end)

If you want this to be a standard feature in your place you may want to do something a bit more scaleable.

One option is connecting this for every animation that plays on your Humanoids (be sure to disconnect it when it is no longer needed). There may also be a much better way of doing this that doesn’t involve keyframe names but the gist will still be the same, pause the animation right before (not on or after) it stopping.

28 Likes

Yeah, it doesn’t work from what I tested just now. I had to re-play the animation once it stops (duh). My bad. Your solution works, too.

Your solution of replaying it may actually be a bit simpiler. Glad you found an answer.

Sorry for reviving this topic, but using animation markers might work out for you.

Here is my solution, for it to work you need to add extra frames to the animation with the position you want to pose, here I added at least 0.1 extra seconds to the animation

local deathAnim = corpse.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.DeathAnim)
repeat wait() until deathAnim.Length ~= 0 
deathAnim:Play()
wait(deathAnim.Length - 0.1)
deathAnim:AdjustSpeed(0)
9 Likes