Hey guys,
Having an issue my top-down view implementation for a project, after a random amount of time, character movement begins to ‘stutter’ as if a force is pushing back on the character, shown in the video below.
https://gyazo.com/e28a8c0f028c1d0b6e9d72dab18eb0bc
The issue doesn’t appear when using a task.wait loop, however, that implementation is dependent on the player’s framerate and induces a little motion sickness, so I’d like to stick with RunService. I’ve also fiddled around with the :BindToRenderStep() method, however, no matter what the priority is, the issue still remains.
Anyone know what might be causing it? The top-down script is the only script affecting the character.
-- Services
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
-- Vars
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character.Humanoid
local Camera = workspace.CurrentCamera
local HeightOffGround = script.Parent.CameraHeightOffGround
-- Functions
Humanoid.AutoRotate = false
Camera.CameraType = "Scriptable"
RunService.Heartbeat:Connect(function(dt)
local Mouse = Player:GetMouse()
local ResultCFrame
Character.HumanoidRootPart.CFrame = CFrame.lookAt(Character.HumanoidRootPart.Position, Vector3.new(Mouse.Hit.X, Character.HumanoidRootPart.Position.Y, Mouse.Hit.Z))
local AboveHeadPosition = Vector3.new(Character.HumanoidRootPart.CFrame.Position.X, HeightOffGround.Value, Character.HumanoidRootPart.CFrame.Position.Z)
local MousePosition = Mouse.Hit.Position
local NewAbovePosition = AboveHeadPosition:Lerp(MousePosition, .15)
ResultCFrame = CFrame.new(NewAbovePosition.X, HeightOffGround.Value, NewAbovePosition.Z) * CFrame.Angles(math.rad(-90), 0 ,0)
Camera.CFrame = Camera.CFrame:Lerp(ResultCFrame, 1 - .01 ^ dt)
end)