Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make the camera less choppy when using lookVectors?

Hi guys, I made a localscript that moves the player forward towards whatever direction that they are facing when they press Q by using lookVectors. It works fine, but does anyone know a way to make it look less choppy when the character moves in the direction that they're facing?

local player = game.Players.LocalPlayer
local character = player.CharacterAdded:wait() or workspace[player.Name]
local RollSpam = true


repeat wait() until player.character.Humanoid

local humanoid = player.character.Humanoid
RollAnim = humanoid:LoadAnimation(script.RollAnim)


game:GetService("UserInputService").InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.Q then
		if RollSpam == true then
			RollSpam = false
			RollAnim:Play()
			wait(0.1)
	local Roll = character:FindFirstChild("HumanoidRootPart")	
		Roll.CFrame = Roll.CFrame + Roll.CFrame.lookVector*15
		wait(1)
		RollSpam = true
 
    	end
	end
end)

Thanks.

1 answer

✓ Accepted answer

https://developer.roblox.com/en-us/api-reference/class/TweenService TweenService is used for gradual interpolation- finding a series of points between the starting pint and the goal and moving smoothly between them. With tweening, this

Roll.CFrame = Roll.CFrame + Roll.CFrame.lookVector*1

would look like this

goal{["CFrame"] = Roll.CFrame.lookVector*1;}
TweenService:Create(part, TweenInfo.new(1), goal)

where TweenInfo(1) is 1 second to complete

1 comment

0

perfect, thats all I needed, thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.