Native IsEntityInWater not working

Hi,
I need to know when a vehicle is underwater. I’m using the native IsEntityInWater and it is acting weirdly.

IsEntityInWater returns true in following cases:

  • If I drive the vehicle on the beach with wheels in water
  • if vehicle is in the sea but not touching bottom ground

IsEntityInWater returns false:

  • if vehicle is in the sea and touching bottom

I couldn’t find another way to detect if vehicle is in water so I’m stuck.
Any help please?

Did you try this native yet? GetEntitySubmergedLevel - FiveM Natives @ Cfx.re Docs

I didn’t know this one. I’m sure I can find a workarround with this.
I will let you know.
Thanks

Unfortunately GetEntitySubmergedLevel can’t be used directly. The vehicle is not out of order when GetEntitySubmergedLevel = 1.

But I found a way to do what I want:

I set a variable to true if vehicle is under water and not drivable.

if IsEntityInWater(veh) and not IsVehicleDriveable(veh, 0) then
isVehUnderWater = true
end

In this case I keep this variable to true even if the vehicle touch the bottom of the sea, so I can do the others actions.
Thank you anyway :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.