Player sinks with character density set to 1

Hi!

I was trying to make it so that the player does not automatically float if he does nothing in the water.

i found a script from this post

local Players = game:GetService("Players")

local HeavyProperties = PhysicalProperties.new(
	1, -- density
	0.3, -- friction
	0.5 -- elasticity
)

local function configurePhysicalProperties(Part)
	if Part:IsA("BasePart") then
		Part.CustomPhysicalProperties = HeavyProperties
	end
end

Players.PlayerAdded:Connect(function (Player)
	Player.CharacterAdded:Connect(function (Character)
		Character.DescendantAdded:Connect(configurePhysicalProperties)

		for _, Part in pairs(Character:GetDescendants()) do
			configurePhysicalProperties(Part)
		end
	end)
end)

The issue is that when i set the density on 1 i sink.
I also never changed the gravity.

So is there anything else affecting the way you float in water?

1 Like

Nope, only culprit is density, you could set it to something like 0.8 or leave it at 1 and swim with space instead

1 Like

Changing it to .85 works. The problem is that in the game I’m trying to make you can wear different oxygen tanks. And depending on which one you wear, you either float or sink. and changing the density every time you wear a different one is a bit tedious

1 Like

Sinking at 1 density is intended behaviour which is what the OP of that linked thread was asking for. If you want different behaviours based on if the player is actively moving or not then you’d have to code that in yourself.

Play around with the Swimming Humanoid state to find out what values you may need to be working with to assume whether the player is moving while swimming or not (note that speed isn’t necessarily non-zero when the player isn’t moving) then use your testing numbers as benchmarks to determine when you need to increase or decrease the character’s density.

You should be changing the density each time you have a new state applied to the character, be it their movement or some system that influences density/player movement.

2 Likes