Saving the Position of an Animation

Hey all, I have an animation where a capsule will roll down a chute, however no matter what I do the animation won’t save its position at the end, it will always reset back to its original position. I’ve tried using Animation:Stopped() and Animation:Ended() to set the speed to 0 or use CFrame to get it to stay in its final position, even naming the keyframe before the last or using animation events, but no matter what it will go back to where it started. I have made sure Looping is off.

local rep = game:GetService("ReplicatedStorage")

local fCapsule = rep.FuelCapsule
local cCapsule = rep.CoolantCapsule
local fcapAnimControl = fCapsule.AnimationController
local ccapAnimControl = cCapsule.AnimationController

local fDelivEvent = rep.FuelCapsuleDeliver
local cDelivEvent = rep.CoolantCapsuleDeliver

local animID = "rbxassetid://15688301435"
local anim = Instance.new("Animation")
anim.AnimationId = animID

local fRollAnim = fcapAnimControl:LoadAnimation(anim)
local cRollAnim = ccapAnimControl:LoadAnimation(anim)

fDelivEvent.Event:Connect(function()
	fRollAnim.Looped = false
	fCapsule.Parent = workspace
	fRollAnim:Play()
end)

--cCapsule will just be a copy of the above script once I finish it.

Hey.
You just do AnimationTrack:AdjustSpeed(0)
This will set the animation play back speed to 0 (pause it)
I believe you have to set the animation position to the end too.

AnimationTrack:AdjustSpeed(0)
animationTrack.TimePosition = animationTrack.Length*99.9

Yeah, I already tried this and it didn’t work unfortunately.

Try this

AnimationTrack:Play()

afterwards to replay it. Incase that is the issue

AnimationTrack:AdjustSpeed(0)
AnimationTrack.TimePosition = animationTrack.Length*99.9
AnimationTrack:Play()

I managed to fix it by using :Destroy() immediately when the keyframe before the last is reached to force it to stay in place, then used CFrame to set the position to where it left off.

1 Like

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