How do I rotate my character smoothly

I am trying to make a shoulder camera for a gun system I am making and I cannot get the character to move smoothly. So far I’ve tried to move the character on Heartbeat, Stepped, RenderStepped, and I’ve tried to tween the character and use a body gyro but to make the character move smoothly, but nothing works (tweening/body gyro is either too slow where it looks really bad or its too fast and still jittery).

When I use RenderStepped:
https://gyazo.com/204ac56f41c16299b4996ae6889adea2
When I use Heartbeat:
https://gyazo.com/c5d7311850ba505842e0a805491953c2
When I use Stepped:
https://gyazo.com/9c2b8fb465506187efb10e41d8abd836
When I tween:
https://gyazo.com/e8a8424002ef94828d66b821a786e8bb (too slow)
https://gyazo.com/4785d54313dd34bf1e52f76c15713d90 (too fast)

Here is my code used for turning the character:

turnListen = runService.RenderStepped:Connect(function()
	local camVector = camera.CFrame.LookVector
	local rootCFrame = CFrame.new(root.Position, Vector3.new(camVector.X * 999, root.Position.Y, camVector.Z * 999))
	root.CFrame = rootCFrame
end)

I’m trying to find a solution that would make the turning something similar to shiftlock like in this gif: https://gyazo.com/85db53c606aa803e46683b43718bdbe9

5 Likes

I believe you can solve it by lerping the CFrame values in order to smoothen it out similar to tweening but not as linear like so. You can adjust the lerp alpha value in order to change how fast you lerp towards the current goal CFrame and such.

turnListen = runService.RenderStepped:Connect(function(step)
	local camVector = camera.CFrame.LookVector
	local rootCFrame = CFrame.new(root.Position, Vector3.new(camVector.X * 999, root.Position.Y, camVector.Z * 999))
local lerpAlpha = 0.25
	root.CFrame = root.CFrame:Lerp(rootCFrame,lerpAlpha)
end)
1 Like

Tweening is smoother than lerping the CFrame

2 Likes

Are you sure about that, where is this coming from? This resource seems to achieve what you are trying to do and it uses lerping to achieve the objectives and I think it’s pretty good.

Looking through the source code perhaps it’s not the only the root CFrame of the character that needs lerping but the camera as well.

		--// Calculate new camera cframe //--
		local newCameraCFrame = CFrame.new(humanoidRootPart.Position) *
			CFrame.Angles(0, self.HorizontalAngle, 0) *
			CFrame.Angles(self.VerticalAngle, 0, 0) *
			CFrame.new(offset)
		
		newCameraCFrame = currentCamera.CFrame:Lerp(newCameraCFrame, activeCameraSettings.LerpSpeed)

IDK, up to you.

2 Likes

Hey, I’m not sure if you’ve found the answer yet but I would suggest using something like this script

game:GetService(“RunService”).RenderStepped:Connect(function()
HumanoidRP.CFrame = CFrame.new(HumanoidRP.CFrame.p, HumanoidRP.CFrame.p +Vector3.new(camera.CFrame.LookVector.X, camera.CFrame.LookVector.Y, camera.CFrame.LookVector.Z))

1 Like
1 Like