LinearVelocity dash direction

So the LinearVelocity dashes in the correct direction, however I can’t seem to get the player to face in the direction they are dodging.

Here is the code for facing the character:

HumanoidRootPart.CFrame =,, 0, DodgeVelocity.Y) * 1000)

And here is the code for getting the velocity direction:

function GetDodgeVelocity()
	local VectorMask =, 0, 1)
	local Direction = HumanoidRootPart.AssemblyLinearVelocity * VectorMask
	if (Direction.Magnitude <= 0.1) then
		Direction = CurrentCamera.CFrame.LookVector * VectorMask
	Direction = Direction.Unit
	local VelocityDirection =, 0, Direction.Z)
	local DodgeVelocity = VelocityDirection * DodgeSpeed
	return DodgeVelocity

Here is en example of what I mean:

How would I get the player to face in the same direction as they are dashing?

1 Like

HumanoidRootPart.CFrame = * CFrame.lookAt(, DodgeVelocity*, 0, 1))

This will instantly snap the character’s look direction to match DodgeVelocity, but personally I’d use an AlignOrientation constraint instead of setting CFrame directly.

Also, CFrame.lookAt(, gives NaNs, so you better check if DodgeVelocity’s Magnitude is > 0 before setting CFrame.


Thank you very much! I will defiantly look into using AlignOrientation instead.

1 Like

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