- Home /
How to implement water buoyancy
How do I do that? I'll have some water in second level of my game and I don't want player just drown.
Answer by tanoshimi · Oct 06, 2013 at 06:14 AM
Buoyancy depends on the relative density of an object to the fluid in which it is floating, together with the degree by which it is covered by the fluid. You'll also probably want to consider drag, which depends on the viscosity of the fluid. If you're using inbuilt Physics, it should be relatively easy to implement these additional forces when the player object is in contact with water, and let the physics engine resolve them automatically.
The easiest way you can implement buoyancy is by giving the buoyant object an appropriate ConstantForce
But buoyancy is not a constant force - it's equal to the weight of fluid displaced by the object. And that depends on the density of the fluid and the volume displaced.
True. I'm working under the assumption that he's not going for realistic physics, but ease of implementation.
Even if he was going for full realistic physics, a ConstantForce only means a force is constantly applied to the rigidbody each physics update, the amount of force could be changed whenever.
And, as we've had no further input from the OP, we're both pretty much guessing what is required anyway! ;)
I want my player being able to swim like in $$anonymous$$inecraft (though game has nothing to do with $$anonymous$$C)
Your answer
Follow this Question
Related Questions
Making an object float in water 2 Answers
3d Water Simulator 1 Answer
How to Script Buoyancy with a Water Shader 2 Answers
Having trouble with player boat movement with buoyancy pack 0 Answers
Bouyancy Effector Issues 0 Answers