One way to simulate water buoyancy in code is to use a physics joint such as a spring joint and attach it to both the character's body and the surface of the water. Then, you can set the force of the spring so that it pushes the character's body up, like a real object floating in water. To get a semi-realistic water buoyancy effect, you can also apply a damping force to the spring joint, so that the character's body doesn't just bob up and down uncontrollably.