Make Player Swim in water

Hello. I was wondering whether it is possible to make the player float in water; the player is running on a race track and when the player touches a pool, the player will start to sink and will have to press the up button to float. I was wondering whether it is possible to do that and what kind of script would I have to use. Do I have to use a buoyancy script then link it to my running script? What is recommended to use in this case? Please advise! Thank you in advance! :slight_smile:

There is an excellently answered related question here. It’s using a modified third-person controller, but the approach is transferable.

That being said, try to break down the components of your problem into the smallest logical pieces. You need to:

  1. detect contact with the water
  2. disable land-type movement and enable water movement
  3. OR add onto land type movement with water movement also

Some things to consider include how or if you want to model buoyancy, how you want the density change of water to affect movement speed (if at all), etc. The easiest way to toggle between the two states is with the OnTriggerStay function.