Im making a top down camera system, with movement using the mouse’s movement.
It uses a part that moves freely in the workspace. The camera is binded by RunService so that it is always moving with the part.
Mouse movement is used in ContextActionService, when the mouse is held, the camera moves.
Unfortunately, movement is jittery. (Most likely that the movement is locked to left and right and such)
I want it so the camera can move smoothly.
For Reference:
What I have right now:
Code:
if InputState == Enum.UserInputState.Change then
if Mouseheld then
local movespeed = 50
local Left = Player_Camera.Position + Vector3.new(-movespeed, 0, 0)
local Right = Player_Camera.Position + Vector3.new(movespeed, 0, 0)
local Up = Player_Camera.Position + Vector3.new(0, 0, -movespeed)
local Down = Player_Camera.Position + Vector3.new(0, 0, movespeed)
if math.abs(Mouse.X - lastMouseX) > math.abs(Mouse.Y - lastMouseY)then
--Player_Camera.Position = Player_Camera.Position + Vector3.new(-movespeed, 0, 0)
if Mouse.X - lastMouseX > 0 then
Player_Camera.WorldPosition = Player_Camera.WorldPosition:Lerp(Left, .1)
else
Player_Camera.WorldPosition = Player_Camera.WorldPosition:Lerp(Right, .1)
end
else
if Mouse.Y - lastMouseY > 0 then
Player_Camera.WorldPosition = Player_Camera.WorldPosition:Lerp(Up, .1)
else
Player_Camera.WorldPosition = Player_Camera.WorldPosition:Lerp(Down, .1)
end
end
lastMouseX, lastMouseY = Mouse.X, Mouse.Y
end
end