I am trying to create movement around a part but when I spam A and D it distances me further away from the center for some reason
Hereβs a clip of it in a different game:
https://youtu.be/8gekoT5Amx8?t=75
Clip of the issue:
https://streamable.com/f6fwhr
local Camera = game.Workspace.CurrentCamera
local Part = game.Workspace:WaitForChild("Part")
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local ForwardMovement = Enum.PlayerActions.CharacterForward
local BackwardMovement = Enum.PlayerActions.CharacterBackward
local function Sink()
return Enum.ContextActionResult.Sink
end
local FocusLoop
game.ReplicatedStorage.FocusMalakai.OnClientEvent:Connect(function(State)
if State then
FocusLoop = RunService.RenderStepped:Connect(function()
Camera.CFrame = CFrame.new(Vector3.new(Camera.CFrame.X, Part.Position.Y + 9, Camera.CFrame.Z), Part.Position) -- my method used to set the camera
end)
ContextActionService:BindAction("SinkForwardMovement", Sink, false, ForwardMovement)
ContextActionService:BindAction("SinkBackwardMovement", Sink, false, BackwardMovement)
else
if FocusLoop then
FocusLoop:Disconnect()
FocusLoop = nil
end
ContextActionService:UnbindAction("SinkForwardMovement")
ContextActionService:UnbindAction("SinkBackwardMovement")
end
end)