Set a rotation Speed

I’m trying to work on some mechanics for a mech. I want to make it controllable with the mouse. I’ve got it set to rotate to the mouse position but its quite fast. Is there a way I can slow it down and set a maximum rotation speed with what I got?

robloxapp-20240408-1640302

Codes pretty basic. This is what I’m using

RunService.RenderStepped:Connect(function() --move mech to cursor
	
	local move = game.Workspace.mini.mech.default -- part the will be moving
	local pos = Vector3.new(mouse.Hit.Position.X,mouse.hit.Position.Y, mouse.Hit.Position.Z) -- mouse position to move to
	
	
	move.CFrame= CFrame.new(move.Position, pos)
	
	
	
end)
1 Like

Since you’re running this during a RenderStep, I would use CFrame:Lerp() to achieve the effect you’re looking for.

So that’s the goal CFrame you have, which can be applied here:

local ALPHA = .25 -- 0-1
move.CFrame = move.CFrame:Lerp(CFrame.new(move.Position, pos), ALPHA)
1 Like

Tried it and it works great, thank you.

1 Like

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