Toggling massless in movement system causing lag spikes

I am creating a movement system that essentially applies a velocity to the character and quickly toggles masslessness on and off when the character dashes, double jumps, or wallclimbs. There is a slight delay when massless is toggled to achieve a snappy effect

When this function is triggeded in studio, it works fine. In a published game, it creates a significant lagspike

this was not an issue when this system was written (around august this year)

  1. What do you want to achieve?
    no lag spike when function is used / new way of achieving the same effect

  2. What is the issue?

Original results before broken:
-Dash, Double Jump, Wallclimb cause no lag

Now broken results:
-Dash, Double Jump, Wallclimb cause lag spike

Studio test shows no issue:

  1. What solutions have you tried so far?

Disabling the function entirely- makes movement system watery
Looked for an update that may have caused this issue- couldn’t

Here is the current function:

-- Function to toggle masslessness of the character's parts
-- This function sets the Massless property of all BaseParts in the character
local function toggleCharacterMassless(self: MovementControl, is: boolean): nil
	assert(humanoid and root, "MovementController/toggleCharacterMassless Humanoid or RootPart not found")

	for _, part in ipairs(character:GetChildren()) do
		if part:IsA("BasePart") then
			part.Massless = is
		end
	end

	return
end
1 Like

solved by using CustomPhysicalProperties and changing density to zero

part.CustomPhysicalProperties = PhysicalProperties.new(is and 0 or 0.7, 0.3, 0.5)

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