I’m using the default animator animation player. The script works fine, but I want the animation to snap to the first keyframe not tween. I have tried things to fix it, but it doesn’t work.
You have to change the easing style to constant
I mean when I play the animation through a script. I want the rig to snap to the animation, without the character having to tween to the animation positions.
You probably want to do something like animationTrack:Play(0)
? The first argument is the fade in time.
I’m doing that but it takes some time to play the animation. Could it be the code:
vent.OpenPrompt.Triggered:Connect(function()
vent["Metal Door Close"]:Play()
task.spawn(function()
game:GetService('TweenService'):Create(vent, TweenInfo.new(.2, Enum.EasingStyle.Sine), {['CFrame'] = CFrame.new(-17.8999634, 1.08929622, -7.38205194, 1, 2.04530437e-08, -5.61942812e-08, 5.61942812e-08, -0.642787635, 0.766044438, -2.04530437e-08, -0.766044438, -0.642787635)}):Play()
end)
local scare = animationPlayer:LoadAnimation(createAnimation(ids.JumpOut))
scare.Looped = false
idle:Stop(0)
scare:Play(0)
print(scare.IsPlaying)
task.spawn(function()
wait(0.1)
task.spawn(function()
stopSounds(true, rig.TopTeeth.CreepyScream)
end)
rig.TopTeeth.CreepyScream:Play()
setRigTransparency(true)
end)
scare.Ended:Connect(function()
print(scare.Length)
idle:Play(0)
setRigTransparency(false)
vent.OpenPrompt:Destroy()
task.spawn(function()
stopSounds(false)
end)
end)
end)
That’s weird since the animation playback is instant for me (once it loads, of course), what’s the chance that the animation is not loaded in by the moment it needs to play so therefore it takes a moment to load?
It could be. I’ll try detecting if the animation is loaded first.
Yeah, you were correct it was due to the animation not being loaded. An easy way to detect if an animation is Loaded, is just by checking if the Length is greater than 0.
If you’d like to try to fix the issue in a better way than yielding the script until it loads, I can recall hearing that ContentProvider.PreloadAsync now interacts with animations correctly and preloads them. Create a folder with animations in ReplicatedStorage or something and preload them on the client. There are some hackier ways to force animations to load, but I’d rather not get into them as it’s rather obnoxious to deal with.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.