On Collision with water buoyancy and play Swim animation

How would i achieve some sort of buoyancy and to tell my player to animate the “Swim” Animation… I have seen some buoyancy scripts but i haven’t really seen one that looks good and im not to sure how to tell a character to play a animation once i enter water. thanks.

So If you have been through any modern Science class you should know a bit about Density.

Programming water at a reasonable cost of memory and CPU Usage and such is a bit of a feat.

So usually we just make either a cube in which has a fancy textured/animated plane on top to make it look nice but colliders are a little bit confusing when we get into this. Since most Colliders well, Collide and prevent objects from going through we run into a wall.
Unity has actually been very good to us Devs and added the option to colliders to add a isTrigger option in which allows an object to pass through it but still detects collisions.

So using OnTriggerEnter, OnTriggerExit, and OnTriggerStay you can detect when the player is in and out etc.

But that usually isn’t good enough to simply achieve the effective no glitches water effect. Making an animation play when the player enters is simple by just detecting when the player enters and using SendMessage you can tell it to play an animation safely inside the object.

But back to the glitching part. Usually before exiting the water the player might be walking on a slope up and to fix any glitches with this you can use RayCasting to the players feet to detect if the player is able to walk.

Hope I could help!