-- Continuously compute a new body orientation to face the camera, and notify the server for replication
-- Intended to be used for the local player's character

function OrientableBody:useCameraAsSource()
	local timeSinceLastSync = 0
	self.renderStepConnection = RunService.RenderStepped:Connect(function(delta)
		local camera = workspace.CurrentCamera
		if not camera then
			return
		end

		local orientation = self:face(camera.CFrame.LookVector)

		timeSinceLastSync += delta
		if timeSinceLastSync > Constants.SYNC_INTERVAL and orientation then
			timeSinceLastSync %= Constants.SYNC_INTERVAL
			updateBodyOrientation:FireServer(orientation)
		end
	end)
end
