How to make the animation smoothly blend into another animation after you start running?

Hello, How do you make it so a walking animation smoothly blends in the running animation? like in evade for example. Is it the matter of scripts or the animation itself? Anyways Heres my current code


local runningAnimation = Instance.new('Animation')
local jumpingAnimation = Instance.new('Animation')
local keyboardButtonPressed = false
local controllerButtonPressed = false

local defaultSpeed = 16 
local sprintSpeed = 21 
local FOV = 80 
local	 walkingFOV = {FieldOfView = FOV}
local sprintFOV = {FieldOfView = FOV + 20} 
local tweenTime = 2
local keyboardButton = Enum.KeyCode.LeftShift 
local controllerButton = Enum.KeyCode.ButtonR1 
local tweenEasingStyle = Enum.EasingStyle.Exponential
local tweenEasingDirection = Enum.EasingDirection.Out
runningAnimation.AnimationId = 'rbxassetid://11179118580' 
jumpingAnimation.AnimationId = 'rbxassetid://11179118580' 
local keepJumpingAnimation = false 

local player = script.Parent
local humanoid = player:WaitForChild("Humanoid",5)
local camera = game.workspace.CurrentCamera
local animator = humanoid:WaitForChild("Animator")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local playRunning = humanoid:LoadAnimation(runningAnimation)
local playJumping = humanoid:LoadAnimation(jumpingAnimation)

local Info = TweenInfo.new(tweenTime, tweenEasingStyle, tweenEasingDirection)
local runningT = TweenService:Create(camera, Info, sprintFOV)
local walkingT = TweenService:Create(camera, Info, walkingFOV)

UserInputService.InputBegan:Connect(function(input,gameProcessedEvent)
	if input.KeyCode == keyboardButton then
		keyboardButtonPressed = true
		while keyboardButtonPressed == true do
			wait()
			humanoid.WalkSpeed = sprintSpeed
		end
	end
	if input.KeyCode == controllerButton then
		controllerButtonPressed = true
		while controllerButtonPressed == true do
			wait()
			humanoid.WalkSpeed = sprintSpeed
		end
	end
end)

UserInputService.InputEnded:Connect(function(input,gameProcessedEvent)
	if input.KeyCode == keyboardButton then
		keyboardButtonPressed = false
		while keyboardButtonPressed == false do
			wait()
			humanoid.WalkSpeed = defaultSpeed
		end
	end
	if input.KeyCode == controllerButton then
		controllerButtonPressed = false
		while controllerButtonPressed == false do
			wait()
			humanoid.WalkSpeed = defaultSpeed
			end
		end
end)

humanoid.Running:Connect(function(Speed)
	if Speed > defaultSpeed + 1 then
			if not playRunning.IsPlaying then
				runningT:Play()
				playRunning:Play()
		end
	else
		walkingT:Play()
		playRunning:Stop()
	end
end)

humanoid.Jumping:Connect(function()
	if playRunning.IsPlaying then
		playRunning:Stop()
		if keepJumpingAnimation == true then
			playJumping:Play()
		end
	end
end)
	playRunning:Stop(--[[blend time]])

blend time is the best at 0.1 because its not that chuby but fast enough to work with.

1 Like

where do you put this in the script?

Anywhere you want to blend animations (or just not stop them instantly)