I'm trying to use JBullet for a ship PVP game.

I've got two ships which are meant to rest on the water. Obviously these ships will be colliding, but the problem I have currently is "water" collision.

Water cannot be a "solid" object, and I cannot work anything out that will allow it to have the ship resting in it without falling over or having some sort of speed dampening effect.

Also, the ships keep being launched upwards or downwards depending on the collision. The problem here is that I cannot set a weight for the ships, because if I did, they would currently be sinking into what JBullet believes to be nothingness.

How would I simulate water in this collision world?


1 Answer 1


Do some manual tracing to determine where in the water the ship is... it could be as simple as checking the Y or Z coordinate being below 0 if your world is all water with the water table at level 0.

Anyway, if the ship is in water, every timestep, push it upward with a force/impulse. The deeper in the water it is, the stronger the push. This should work pretty well, once you get the force levels worked out, it should quickly find a balance point - perhaps with a bit of bobbing as your push-up code and gravity fight each other a microbit, but it should be small enough to not be a problem.

  • \$\begingroup\$ I've tried this and it appears to work. The ships are now at the correct height. :) Unfortunately now the ships don't want to collide - But that's unrelated and I'll be posting it in a separate question. \$\endgroup\$
    – joehot200
    Apr 18, 2015 at 23:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .