Rope uncoil animation (Animation not completing or finishing length?)

I am attempting to have a rope uncoil animation play to the point of a rope becoming completely untangled.
The animation within the default Roblox plugin plays the desired way, as seen in this gif.
howitshouldlook

This animation was produced with the default Roblox animator.
This animation has a length of:
image

The issue appears when playing the animation with code

Here is the code in question:

local RopePackage = script.Parent
local SkinnedMeshAnimations = RopePackage.SkinnedMeshAnimations
 
local animationRopeWrapped = SkinnedMeshAnimations.RopeWrapped
local animationRopeUnwrapped = SkinnedMeshAnimations.RopeUnwrapped

local AnimationController = RopePackage.AnimationController
local Animator = AnimationController.Animator

local animationTrack1 = Animator:LoadAnimation(animationRopeWrapped)
local animationTrack2 = Animator:LoadAnimation(animationRopeUnwrapped)

function checkFreezeAnimationAtPercent(animationTrack, percentagePosition)
	local timePos = animationTrack.TimePosition / animationTrack.Length
	if timePos >= percentagePosition then
		animationTrack:AdjustSpeed(0)
	end
end

if animationTrack1 then
	animationTrack1:Play()
end
wait(3)
if animationTrack2 then
	animationTrack2:Play()
end

Connection = RunService.Stepped:Connect(function()
	checkFreezeAnimationAtPercent(animationTrack2, .99)
end)

Where RopePackage is a model instance that looks like this:
image

Where RopeWrapped and RopeUnwrapped are of the Animation class with the respective Id

This code creates a runtime that looks like this:
rope unravel

Without the function checkFreezeAnimationAtPercent The animation looks like this:
rope unravel without stop

Intimal thoughts were figuring out why there was a discrepancy between the length that the default Roblox animator said it was, vs what reading the code via Animaiton.Length

If I print the length it is given as:

This created a discrepancy from 1.19 to 1.633. This makes me wonder if the animation uploaded with seemingly two different lengths, or how that could have happened.

The issue can’t be with checkFreezeAnimationAtPercent as even without running that code, the animation restarts sooner than the supposed ending.

There is no code messing with the animation thereafter the snippet shown in this post.

Any ideas on the nature of animations on Roblox are appreciated, thank you.

3 Likes

It’s a little confusing, but the scrubber time in the editor is second:frame. So your animation length is 1 + (19 frames / 30 FPS) = 1.63 seconds. I’m not as keen on the playback issue, but I’m willing to troubleshoot if you post/message me the model with the KeyframeSequence.

Edit: The first animation was interfering with the second. For future thread viewers, the solution was to stop the first before playing the second, but there may be an equivalent fix involving animation priority.

2 Likes

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