When changing the AssemblyMass of a player character during run-time while using the new GroundController, AirController, etc. the character will become unstable. Increasing the mass will cause the character to ‘shake’ while standing in place and any slight movement could cause the character to trip and fall over. The heavier the character, the more unstable they become.
Below are two videos demonstrating what is happening at different masses. The character’s weight was changed by setting all BaseParts under the character instance to
Massless = true, except for the HumanoidRootPart whose density was increased to change the AssemblyMass. My player character’s AssemblyMass is normally 13.77 units when no code is used to change the mass.
When increasing the AssemblyMass to 16 units, the character will start shaking as seen in the video below:
When I increase the AssemblyMass to a whopping 160 units, any unexpected change of movement will cause the character to fall over immediately:
For gameplay purposes I want the characters in my game to all have the same weight, but unfortunately this behavior prevents me from using the physics controllers if I do so.
- Add a Humanoid named
StarterHumanoidto the StarterPlayer folder with a ControllerManager and any of the physics controller instances as children.
- Insert the following code into a Script inside the ServerScriptService.
local PLAYER_MASS = 160 -- change this to see how the behavior changes at different weights function fixMass(Obj: BasePart) if Obj.Name ~= "HumanoidRootPart" then Obj.Massless = true else local propertiesOld = PhysicalProperties.new(Obj.Material) local properties = PhysicalProperties.new( PLAYER_MASS / (Obj.Size.X * Obj.Size.Y * Obj.Size.Z), propertiesOld.Friction, propertiesOld.Elasticity, propertiesOld.FrictionWeight, propertiesOld.ElasticityWeight ) Obj.CustomPhysicalProperties = properties Obj:GetPropertyChangedSignal("Size"):Connect( -- for some reason the HumanoidRootPart's Size changes after CharacterAdded is already called? function() properties = PhysicalProperties.new( PLAYER_MASS / (Obj.Size.X * Obj.Size.Y * Obj.Size.Z), propertiesOld.Friction, propertiesOld.Elasticity, propertiesOld.FrictionWeight, propertiesOld.ElasticityWeight ) Obj.CustomPhysicalProperties = properties end ) end end game.Players.PlayerAdded:Connect( function(Plr) Plr.CharacterAdded:Connect( function(Character) local P = Character:GetDescendants() for i = 1, #P do if P[i]:IsA("BasePart") then fixMass(P[i]) end end Character.DescendantAdded:Connect( function(Obj) if Obj:IsA("BasePart") then fixMass(Obj) end end ) end ) end )
- Run the game and observe how the character will trip when you rotate too much.