How to make a smoother transition between two animations

Hello, I’ve been trying to figure out how to make a transition between two animations more smoother, I have tried using AnimationTrack:Play(fadeTime) but when you set a fade time it seems to be a linear fade, I’d like to achieve something more like a “Sine” fade, I don’t know if that makes sense.

A good example of what I want to achieve is from the game Write a Letter which has really good animation transitions, here a video.

I want to believe this is possible without having to make an animate script from scratch, I’d prefer to edit the one that roblox provides.

Any help would be really appreciated.

5 Likes

Hey Vobees!

For this matter, you should read about the Animation Weight Adjustment!

Hope that helps!

First, thank you for replying, I appreciate it a lot.

Second, I already have tried using weight to achieve this but I haven’t been able to find similar results, the animation still does a linear fade or the animation just doesn’t work at all.

I even tried using the second parameter of AdjustWeight which is fadeTime, and I still haven’t been able to find similar results.

Well, I don’t think there is currently a built-in mechanism to select the way the animation fades out.

However, for the smooth transition, you can also try to AdjustWeight both ways: smoothly adjust the old animation weight to 0, and the new one from 0 to the weight you like (where 1 is default).

Let me know if this one worked out!

1 Like

I have tried what you said, and I don’t think is similar at all, it definitely made it somewhat smoother but not in the way i wanted.

Another way to call what I want to achieve is trying to “lerp” the transition, basically make it so when the animation plays, you can see it slows at the end, giving that effect of smoothness.

Here is the code that my animate script uses, I may be doing something wrong and I am just being silly.

if (currentAnimTrack ~= nil) then
	currentAnimTrack:AdjustWeight(0, 0.5)
	currentAnimTrack:Destroy()
end

currentAnimSpeed = 1.0

-- load it to the humanoid; get AnimationTrack
currentAnimTrack = animator:LoadAnimation(anim)
currentAnimTrack.Priority = Enum.AnimationPriority.Core

-- play the animation
currentAnimTrack:Play(transitionTime, 0)
currentAnim = animName
currentAnimInstance = anim
		
currentAnimTrack:AdjustWeight(1, 0.5)
10 Likes

Hey there! I love the camera shaking or bobbing when you walk! Is there any tutorial on how to do that? Back on topic, thank you!

Hey, I found a method for creating the smooth “sine” transition by having a tween tween the weight as the animation plays. I hope this helps^^

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://17862783974"

local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)

local TweenService = game:GetService("TweenService")
local NumberValue = Instance.new("NumberValue")
local Tween = TweenService:Create(NumberValue, TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut), {Value = 1})

NumberValue:GetPropertyChangedSignal("Value"):Connect(function()
	animationTrack:AdjustWeight(NumberValue.Value)
	print(NumberValue.Value)
end)

task.wait(2)
Tween:Play()
animationTrack:Play()

Turns out you can also do it just by putting the AdjustWeight() function into a heartbeat loop

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://17862783974"

local humanoid = script.Parent:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local animationTrack = animator:LoadAnimation(animation)
animationTrack:AdjustWeight(0)

local Playing = false

game:GetService("RunService").Heartbeat:Connect(function()
	if Playing then
		animationTrack:AdjustWeight(1)
	else
		animationTrack:AdjustWeight(0.05) -- if you set it to 0 the animation won't replicate properly bc of a roblox bug
	end
end)

task.wait(2)
Playing = true
animationTrack:Play()

task.wait(2)
Playing = false
animationTrack:Stop()
2 Likes