Tweeing velocities

I noticed that there are many replies that say that you should tween something like a body velocity or linear velocity to make dashing smoother, but there are no tutorials or topics that say how you should do that. So, I’m asking, how do I tween the body velocity?

Hey, velocities can be tweened fairly easily. I’ll use a LinearVelocity as an example:
Assuming you’re using Vector velocity:

local TweenService = game:GetService("TweenService")

local My_Velocity = ...

local function TweenOnce(...)
	local t = TweenService:Create(...)
	t.Completed:Once(function()
		t:Destroy()
	end)
	t:Play()
end

My_Velocity.VectorVelocity = Vector3.new(10,0,0)
TweenOnce(My_Velocity,TweenInfo.new(1),{
	VectorVelocity = Vector3.new(0,0,0);
})

There are many different ways to do this, the TweenOnce function is just used to help clean up tweens once they are finished.

If you have any questions, please let me know!

1 Like

Yeah, that works. Another question I have is how would I stack multiple tweens to create one smooth dash?

You can modify the TweenOnce function to yield the current thread, if you’d like to have tweens play consecutively.

local function TweenOnce(...)
	local t = TweenService:Create(...)
	t:Play()
	t.Completed:Wait() -- will yield the current thread until the tween finishes
	t:Destroy()
end
1 Like

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