# Simulating an object floating on water

I'm working on a top down fishing game. I want to implement some physics and collision detection regarding the boat moving around the lake. I would like for be able to implement thrust from either the main motor or trolling motor, the effect of wind on the object, and the drag of the water on the object.

I've been looking at the farseer physics engine, but not having any experience using a physics engine, I am not quite sure that farseer is suitable for this type of thing(Most of the demos seem to be the application of gravity to a vertical top/down type model).

Would the farseer engine be suitable? or would a different engine be more suitable?

-

## migrated from stackoverflow.comMar 5 '11 at 8:26

This question came from our site for professional and enthusiast programmers.

I'm doing this kind of thing with bullet, but the same technique could be used with any physics engine. Buoyancy is modelled by attaching imaginary floats to the body which simply apply a force acording to their depth below the surface at discrete points.

In the timestep the each float tests the water level at their position, then applies a force to the boat's rigid body at their position relative to the boat. I imagine each float as a cylinder which is always vertical, regardles of the orientation of the boat. The force is proportional to how deeply immersed they are, up to a maximum defined by their volume.

At the moment the boat has just 4 floats - bow, stern, port & starboard. I manually set their volumes to provide enough force to counteract gravity, and then adjust the positions and cylinder lengths to tweak the way the boat moves. I've got a vague idea to generate the floats by packing cylinders into the rigid body volume somehow, but that's something for the future.

A short demo of a boat sailing through waves is here on youtube.

-

Farseer physics supports all kinds of force and intertia application, so that wouldn't be a problem, I'm not 100% sure though if Farseer already supports fluid bodies (for the water) but if that's supported then it should be ok. (Also note that Farseer is a 2D physics engine)

-
I think they are adding support for fluids in next version of Farseer (3.3) – brainydexter Mar 6 '11 at 9:18