Added Water Drag and Resistance


New Features

  • Automatic Water Surface Detection on Start:

    • If targetSurface is not manually assigned, the script now searches for the first WaterSurface component in the scene during Start().

    • Automatically enables buoyancy when a valid water surface is found.

  • Water Resistance (Drag) Simulation:

    • Added ApplyWaterResistance() method, which applies a drag force proportional to the object's velocity while in water.

    • New public variable waterDrag added to control drag strength.

 Code Changes

  • Modified Start() to include automatic WaterSurface detection logic.

  • Added ApplyWaterResistance() to FixedUpdate() to simulate underwater drag.

  • Introduced waterDrag float for easy tuning of resistance force.

  • Ensured velocity damping uses ForceMode.VelocityChange for consistent results.

 Configuration

  • New Inspector Field: waterDrag (default: 1.5) — adjusts water resistance intensity.

Files

Unity-HDRP-WaterBuoyancy-DragUpdate.unitypackage 23 kB
1 day ago

Get Buoyancy Water Physics | HDRP Unity 6.000

Buy Now$2.99 USD or more

Leave a comment

Log in with itch.io to leave a comment.