How do I remove friction completely?

I’m making a knockback for a punch, and I’m having different results depending on what the FloorMaterial. e.g Air and plastic

I’ve removed all friction from game.Workspace with a for loop that gets Descendants, and also lowered the speed characters travel through air or when falling down.

Removes friction from game.Workspace

for i,v in pairs(game:GetService("Workspace"):GetDescendants()) do
		if (v.ClassName == "Part" or v.ClassName == "MeshPart" or v.ClassName == "CornerWedgePart" or v.ClassName == "WedgePart" or v.ClassName == "SpawnLocation") then
			local density = 1;
			local friction = 0;
			local elasticity = 0;
			local frictionWeight = 0;
			local elasticityWeight = 0;
			v.CustomPhysicalProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight);
		end;
	end;

Knockback

local heartbeat = nil;
	local timePassed = 0;
	
	local hum = hit.Parent:FindFirstChild("Humanoid");
	
	heartbeat = runService.Heartbeat:Connect(function(dt)
-- If player is freefalling it halves the the speed of AssemblyLinearVelocity
		if (hum:GetState() == Enum.HumanoidStateType.Freefall or hum:GetState() == Enum.HumanoidStateType.Ragdoll or hum:GetState() == Enum.HumanoidStateType.Flying or hum.FloorMaterial == "Air") then
			hrp.AssemblyLinearVelocity = Vector3.new(lookVector.X * velocityNum / 2, 0, lookVector.Z * velocityNum / 2);
		else
			hrp.AssemblyLinearVelocity = Vector3.new(lookVector.X * velocityNum, 0, lookVector.Z * velocityNum);
		end;
		
		timePassed += dt;
         -- Time Limit is set to 5 seconds outside the scope
		if (timePassed >= timeLimit) then 
			heartbeat:Disconnect();
            -- Slows down player at 10% of speed per 1/10 second
			while (hrp.AssemblyLinearVelocity.X > 0 and hrp.AssemblyLinearVelocity.Y > 0 and  hrp.AssemblyLinearVelocity.Z > 0) do 
				hrp.AssemblyLinearVelocity = Vector3.new(hrp.AssemblyLinearVelocity.X - hrp.AssemblyLinearVelocity.X * 0.1, hrp.AssemblyLinearVelocity.Y - hrp.AssemblyLinearVelocity.Y * 0.1, hrp.AssemblyLinearVelocity.Z - hrp.AssemblyLinearVelocity.Z * 0.1);
				task.wait(0.01);
			end;
			
			if (hit.Parent:FindFirstChild("Humanoid")) then
				hit.Parent["Humanoid"].AutoRotate = true;	
			end;
			return;
		end;
	end);

Result:

On Surface
1

In Air
2

Character travels further in air, compared to surface even after removing friction from game.Workspace.

1 Like

Rather than removing friction, I suggest increasing the MaxForce of the BodyVelocity.

I know a lot of people still use BodyVelocity, but I have now defaulted to using Mover Constraints since BodyVelocity is deprecated.

Thanks for feedback

Your code doesn’t actually set every part to have zero friction, you need to set FrictionWeight to 100 so that its friction matters more during collisions.

thanks thanks thanks thanks thanks thanks

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