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)
11 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()
1 Like

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()
11 Likes

Honestly a lifesaver, been trying to get smooth transitions from walking and sprinting on guns this will help alot

1 Like

I know this is an older post but hear me out,

Im using exactly the same idea for an aiming animation for a gun but Im using like a ‘lerp’ calculation every render instead of tweening it. So I have a variable that is being ‘lerped’ to a certain target value and Im using track:AdjustWeight() every frame.
The method is really smooth but I have one main concern: It seems like the Track:AdjustWeight()
function is not meant to be ran every frame, because there’s this built in ‘fade time’ which is supposed to do the ‘smoothing’ job. I’m just generally concerned if this is good for performance.
It would be awesome if you could directly change the animation weight like Track.WeightCurrent = 1, but currently this property is read only.

In conclusion my main question is: Could this method hurt performance? Is it worth the smoothness?

Thanks