So I am trying to make a game that includes rafts and boats and stuff like that and while testing the game I found out when the player jumps onto an unanchored pallet it swings in a circle as if all the weight of the pallet was in the middle. Is there any way I can adjust the weight or center of mass of an object or player?
CustomPhysicalProperties allows for the changing of some properties such as the mass or weight. It is mostly easy to follow.
You can set the properties like this: (This is from the API) – Link to API
local density = .3
local friction = .1
local elasticity = 1
local frictionWeight = 1
local elasticityWeight = 1
PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
part.CustomPhysicalProperties = physProperties
Density = Mass/Volume
Therefore, Mass = Density x Volume
So by reducing the volume or the density, a part’s mass will be decreased. You won’t want to change the volume of players, but as mentioned above, you can change their density using CustomPhysicalProperties
First, you have to know the mass you want each body part to be set to. You can use this, and repeat for each body part.
-- Script in ServerScriptService
game:GetService'Players'.PlayerAdded:Connect(function(plr) -- Player Joins
plr.CharacterAdded:Connect(function(chr) -- Character Spawns
task.wait(0.1)
local TargetDensity = 0.1
local FRICTION = 0.5
local ELASTICITY = 1
local FRICTION_WEIGHT = 0.3
local ELASTICITY_WEIGHT = 1
local BP = chr.LowerTorso -- Change this to the right body part (You could do this for all body parts individually if you'd like)
local DesiredMass = 6.176 -- Change this to the final mass you want the part to be
BP.Massless = false
BP.CustomPhysicalProperties = PhysicalProperties.new(TargetDensity, FRICTION, ELASTICITY, FRICTION_WEIGHT, ELASTICITY_WEIGHT)
local Volume = BP.Mass / BP.CustomPhysicalProperties.Density
local OTargetDensity = Volume*(DesiredMass)
local Modifier = DesiredMass/(Volume*OTargetDensity) -- This will adjust the offput of the mass to make it the DesiredMass
local TargetDensity = Volume*(DesiredMass * Modifier)
local physProperties = PhysicalProperties.new(TargetDensity, FRICTION, ELASTICITY, FRICTION_WEIGHT, ELASTICITY_WEIGHT)
BP.CustomPhysicalProperties = physProperties
print(BP.Name.. " Has a Mass of: ".. BP.Mass) -- Prints the body part name and the body part mass
end)
end)