Animation got laggy when moving out of the grid

I’m currently making a walking forward animation for an NPC, and when you play, the player camera will change to the NPC camera. using this script:

repeat
	wait()
	cam.CameraType = Enum.CameraType.Scriptable
until
cam.CameraType == Enum.CameraType.Scriptable
local function Cam()
		camera.CFrame = camPart.CFrame
end
connection = game:GetService("RunService").RenderStepped:Connect(Cam)

Well, the script works perfectly fine on other animations, but for this walking animation, if you look at the server side, the animation works smoothly and goes forward, but if the player cam attaches to the NPC cam, the frame gets really choppy (the Ping is totally fine), After a few tests, I noticed that whenever the NPC moved out of the grid, the animation got laggy in NPC view (The player cam attaches to NPC cam).

Picture

Some solutions I have tried:

  • Unarchored the humanoidrootpart ( I read somewhere they say if you don’t archor the humanoid rootpart, the grid will move with the animation), not working
  • Using move to to move the NPC to the destination, The only problem with this is that the animation won’t fit smoothly and move well with the animation I made.
  • Using moon animator probably work, but i need the animation event from “animation editor” (i don’t know if marker from “moon animator” work like animation event from “animation editor”)

Question
Can I somehow move the grid with the animation, or maybe have a bigger grid?
Or maybe some solution that can stop the lag

3 Likes

Why not just use Camera Subject?

repeat
	wait()
	cam.CameraType = Enum.CameraType.Scriptable
until
cam.CameraType == Enum.CameraType.Scriptable

cam.CameraSubject = camPart

1 Like

Couldnt attach to the head, maybe i did something wrong, here is the code:

local cam = workspace.CurrentCamera
local camPart = game.Workspace.NPC.Head (is this suppose to go to humanoid? if so then it still wont work)
repeat
	wait()
	cam.CameraType = Enum.CameraType.Scriptable
until
cam.CameraType == Enum.CameraType.Scriptable

cam.CameraSubject = camPart

Keep in mind that I’m attempting to create an NPC’s POV.

1 Like

For a POV you would have to set the min/max zoom distance as well.

Sorry for the late reply. Well, using the script above already puts the player’s camera into the NPC’s camera, so it’s not really a problem with the POV, but the animation got lagging when moving out of the grid.

to clarify: setting the subject to the humanoid is default behaviour for the camera. (If you wanted to reset the camera, you set the subject to the humanoid)