How to know when a part is floating in terrain water

A part is bouyant, we put it in water, and it floats… but how do we measure that?
And if it is part of an assembly (a model welded together), it is floating if and only if the whole assembly is, it inherits the behavior, because it is just one big floating mass after all.
I just want to know if there’s a part.Floating kind of thing you can do.

1 Like

You can use region3 and make a region3 above the water and from the region checking for parts inside the region, also by this you can check if the parent of the part in the region is a model and if the model is named whatever you named the boat, so if it’s floating you can have it for instance print(“floating”)

It will be something like this:

local region = Region3.new(Vector3.new(1,1,1), Vector3.new(15,15,15)) --Size this to what you want it to be
----Part to show in workspace to show region (not needed)
local part = Instance.new("Part",game.Workspace)
part.Anchored = true
part.Size = region.Size 
part.CFrame = region.CFrame
part.CanCollide = false
part.Transparency = 0.5
part.Color = Color3.new(0,255,0)


while true do
wait(1)
local partsInRegion = workspace:FindPartsInRegion3(region,part,1000)
for i,v in pairs(partsInRegion) do
if v.Parent:IsA("Model") and v.Parent.Name == "Boat" then
print("Boat found in region.")
  end
end
end

Edit, my bad I didn’t write “v” down that’s what it’d roughly be like I guess.

If you don’t know much about region3 I recommend rather watching SteadyOn’s video on how to do it, as that’s how I figured out how to do it ages back.
Or on: https://developer.roblox.com/en-us/api-reference/datatype/Region3

Another way you can check is by checking with CFrame so you can see if a certain position of the model of the boat is above the water and if it is then you can print that it’s floating.

5 Likes