Bug when setting a Part's FrictionWeight to 0

When two parts with FrictionWeight = 0 bounce on top of each other, both parts disappear. Sometimes, a giant shadow (like the one in the gif) appears.

2016-02-18_20-20-01.gif

After disappearing, their Positions are set to (nan, nan, nan) and their Rotation is set to (nan, 90, 0). Here’s a quick repo, just paste it into the command bar and run.

local Base = Instance.new("Part", workspace)
Base.Size = Vector3.new(100, 4, 100)
Base.Anchored = true
Base.CFrame = CFrame.new(0, 20, 0)

local Part1 = Instance.new("Part", workspace)
Part1.CustomPhysicalProperties = PhysicalProperties.new(0.7, 0.3, 0.5, 0, 1)  -- default values except for FrictionWeight
Part1.CFrame = Base.CFrame * CFrame.new(0, 40, 0)

local Part2 = Part1:Clone()
Part2.Parent = workspace
Part2.CFrame = Part1.CFrame * CFrame.new(0, 2, 0)

frictionweight_glitch.rbxl (10.1 KB)
This does not happen when only Friction is set to 0.

EDIT: This happens whenever two parts with FrictionWeight = 0 collide.

2016-02-18_20-30-49.gif

The friction between two parts is apparently calculated as a weighted average, i.e. (friction0*weight0 + friction1*weight1)/(weight0 + weight1). If the sum of weights is zero, you get division by zero.

A good fix would be to check for weight equality before getting the average: If the weights are equal, apply the friction of either part. If they’re not, use the weighted average.

1 Like

According to the formula this is expected behaviour, so you should modify the physical properties of the parts like @ScrapYard suggests.

Apparently my divide by zero guard is not very good. Will fix. Hmmm, I’m trying to figure out the ideal behavior for this. Should they interact as if the friction weight between them is the same (meaning just the average of their frictions) or what the math does now where the result should be 0.

For me the latter would be preferable and makes more sense conceptually. If I have a part without any friction weight then I probably don’t want it to influence the friction value with another part, regardless of that other part’s friction weight. (so also if the other friction weight is 0)

I think the two parts should interact as if their friction weights are the same and non-zero.

1 Like