Context:
- I have a terrain flooding system that spawns terrain water into workspace that rises in level over time.
- There are parts in there that I want to float, that should float normally in terrain water.
- None of them are anchored or have modified physics, just plastic, but there are also plastic parts that I don’t want to float.
- I have a script that correctly sorts all of the parts I want to float and it puts them in a table.
- Due to the nature of this game, it’s not reasonable to modify the physical properties of every part.
Problem:
- When I spawn the water and it rises, the parts don’t seem to realize they are in water as far as Roblox Physics are concerned.
- If I swim over and touch one of these parts, it immediately starts to float as it’s supposed to, which I figure is because my touching it has now caused the physics to check and it realizes it’s in water.
- After a part has been touched, it properly responds and will keep floating with the rising water.
- If I let the water stand there long enough (sometimes minutes), eventually the parts will float to the top of the water.
What I want to happen:
I want after the terrain is spawned for the parts to recognize and act like they are in water and float with the rising water. Basically, for the physics to respond just as they would if the water was there already and not scripted.
What I’ve Tried:
-
Testing to confirm if it was the physics, I’ve manually set the density of the part low, to 2, which should definitely make the part float, it does not float.
Note: In the right corner, you can see, rig of my avatar floats properly from the beginning, but not any parts or unions, which should all be floating.
-
Testing to confirm whether or not it was the fact that I spawned the water with a script, I used the part with no custom physics and made some water around it in Studio, ran it, and with no problem, the part just floated right to the top of the water like it’s supposed to.
- I tried using raycasting so see if I could get the part’s position in respect to the water so that I could nudge it with force under the water, but I couldn’t seem to get the water to detect when it was submerged in water. If I raycast straight down from the part, I can get it to return that there’s terrain water…
local startPosition = part.Position + Vector3.new(0, part.Size.Y / 2 + offset, 0) -- Position slightly above the top center of the part
local endPosition = Vector3.new(0, -1000, 0) -- Aimed straight down with a good distance to check.
When I do this, I get the return:
14:25:45.505 Raycast material value: Enum.Material.Water - Server - Terrain Nudge Test:46
14:25:45.505 Applying nudge... - Server - Terrain Nudge Test:64
However, I’ve yet to be able to get it to properly detect the water if I aim the raycast anywhere over the top of the part to see if it is submerged.
- I’ve tried to use buoyancy or clone in fictitious floats, but anything that I do like that seems to mess with the parts too much before the water hits them, sometimes even the littlest thing sends things flying long before the water hits.
It’s important to note that the goal is to just get them to behave normally and to have them properly respond to the water when it rises, and not have them behave abnormally or strangely before the water rises.
I’ve got a script that gets all of these parts and puts them in a table.
Now I’m left with this…
for _, part in ipairs(floatingParts) do
-- Everything I do to them seems to fail to fix the issue.
end
Does anyone have any idea what I can do to an object that without messing up the object’s physics sitting there on the ground, might be able to periodically get it to do something to nudge a physics check so it will realize it’s in water and start responding normally?
Any help would be greatly appreciated.