AlignPosition Follow Movement Jitter

for i, visual in ipairs(self.Visuals) do
			local worldOffset = centerCFrame:VectorToWorldSpace(visual.BaseOffset)
			local targetPosition = centerCFrame.Position + worldOffset
			targetPosition = Vector3.new(targetPosition.X, self.FloorY, targetPosition.Z)

			visual.Attachment.WorldPosition = targetPosition
			visual.Part.Position = targetPosition
			
			local data = self.Troops[i]
			local npc = data.Model
			local offsetY = npc.Torso.Size.Y / 2 + npc["Right Leg"].Size.Y - 0.15
		
			data.AP.Position = visual.Attachment.WorldPosition + Vector3.new(0, offsetY, 0)
		end

Simple follow movement made with AlignPosition, each NPC has an attachment in its root part linked to an AlignPosition that is updated with renderstep. The problem is that movement jitters when playing on 240 fps. For some reason, the jitter is gone when shiftlock is enabled or when on 60 fps.

The NPCs are created on the clientside. The AlignPosition has 10000 MaxForce, 100 MaxVelocity, and 40 Responsiveness.

1 Like

Try updating it in hearbeat instead!

Tried stepped, heartbeat, post simulation, no changes.

did you do it like this?

RunService.Heartbeat:Connect(function(dt)
	for i, visual in ipairs(self.Visuals) do
		local worldOffset = centerCFrame:VectorToWorldSpace(visual.BaseOffset)
		local targetPosition = centerCFrame.Position + worldOffset
		targetPosition = Vector3.new(targetPosition.X, self.FloorY, targetPosition.Z)

		visual.Attachment.WorldPosition = targetPosition
		visual.Part.Position = targetPosition
		
		local data = self.Troops[i]
		local npc = data.Model
		local offsetY = npc.Torso.Size.Y / 2 + npc["Right Leg"].Size.Y - 0.15
		
		data.AP.Position = visual.Attachment.WorldPosition + Vector3.new(0, offsetY, 0)
	end
end)

also try enabling the rigidity property and make values bigger like this

AP.MaxForce = math.huge
AP.MaxVelocity = math.huge
AP.Responsiveness = 200
AP.RigidityEnabled = true

and remove this line

visual.Part.Position = targetPosition

so the constraint handle the movement alone

finally set network ownership too

npc.PrimaryPart:SetNetworkOwner(nil)

hope it works now :smile:

it doesn’t jitter; you are linking objects to an instance which is already moving in steps
the camera you are using smoothes it away - therefore you haven’t noticed this before
you can verify it by looking into the CameraController built-in script

The attachments were not synced to the character position, which unsynced the movement and caused the visual jitter. Parenting the attachments to the character humanoidrootpart and using two attachment mode fixed the issue.

it haven’t “solved” anything
you have just found a combination of factors which suits your specific needs at this point
the problem is not solved

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.