Hello! I was wondering if there is anyway to script it so that a person’s buoyancy level would be so high that the person would float in water. Is that possible?
Hey @BMWLux.
Roblox avatars already have the physical properties to float in water, without pressing space you will eventually float all the way back up.
If you’d like to adjust exactly how bouyant your avatar is, then you can do so by altering the “CustomPhysicalProperties” property in each of the parts of the avatar.
A simple example of this can be found here, and it is as follows.
local part = script.Parent
-- The properties to set
-- This will make the part light and bouncy!
local density = .3
local friction = .1
local elasticity = 1
local frictionWeight = 1
local elasticityWeight = 1
-- Construct new PhysicalProperties and set
local physProperties = PhysicalProperties.new(density, friction, elasticity, frictionWeight, elasticityWeight)
part.CustomPhysicalProperties = physProperties
In this example, the property you’re looking for is “density”, the lower that value is, the faster your avatar will float upward. Similarly, if you make that value higher you can slow the floating, or reverse it and have avatars sink instead.
Hope that helped.
This will work but only in accordance with the official Roblox water block.
I did some experimenting, and it turns out that a part with a density of exactly 1 will not sink (Unless there are other forces acting on it), but won’t float either (It will just stay where it is, and won’t move. It can still rotate in place however.).
Parts with a density of less than 1 will indeed float (The part in the screenshot below has a density of 0.5).
Another thing I’ve noticed is if the density of the part is 0.5, then roughly half of the part will be submerged in water, and the other half won’t be.
So I guess we can develop a formula to figure out roughly how ‘buoyant’ the part will be.
1-(1*density)
If the formula returns 1, that means the part is very buoyant, and if the part returns 0, that means the part is not buoyant.
So, in a script, you could set the density of the player’s humanoid root part to like 0.4 to make them float, or set their density to 1.1 to make them sink.
local physProperties = PhysicalProperties.new(.4, .5, .1, 1, 1)
players_humanoid_root_part.CustomPhysicalProperties = physProperties
or
local physProperties = PhysicalProperties.new(1.1, .5, .1, 1, 1)
players_humanoid_root_part.CustomPhysicalProperties = physProperties
Note that since the player has other body parts attached to it, the humanoid root part will not abide by the formula we developed earlier, so to get around this you’ll either have to play around with density levels, or set everything except for the humanoid root part to massless. (The character acts really weird if you set everything except the humanoid root part to massless)
Also, don’t set the HumanoidRootPart’s mass to any higher than 5 or 10, as it will make the character act really weird.
The question is vague, tell us properly what u want to do
Thanks man this helps so much!! Im making a game where you just drift off into a ocean and eventually after like a hour you find land XD, basically a vibe game with the song “Waves” playing in the background lol
how can you make it be affected by waves?