Boat Sim Notes: Water friction simulation (With interactive demo)

This is an early game prototype. If loaded correctly you should be watching the above  interactive HTML5 Demo. Use WASD keys to move the blue circle. (Or tap|click and hold on a position to attract the circle).

The simulation is made with Box2D physics on Defold engine. The orange square, the circle and the gray boat are just standard collision objects with some linear and angular damping, while gravity is null.

The fun is in the Green Boat!

For any other objects, linear and angular damping was fine to give a sense of water resistance. But my green boat need a more realistic approach, it has a shape, and it should affect the simulation. The boat needs more viscosity force affecting the lateral motion!

Boat Sim Notes: Water friction simulation (With interactive demo)

Viscosity friction is proportional to the velocity, and the vector points opposite. So i needed to get the Lateral Velocity (Lv), projecting the linear velocity (V) onto the axis perpendicular to the boat facing direction. Let’s call the last one as Pd, and make it normalized (length = 1).

We get an scalar getting the projection with the dot product:  S = V, Pd).

Then the lateral velocity vector is:  Lv = Pd * S (assuming Pd is normalized).

Finally our opposite force is: F = – Lv * (Where K is “made up” constant 😛 ).

Applying this force to the center of mass of the object on every frame and that’s it!

For more realism in not-so-low speeds I think we should use the square of the velocity. But without it we also get the effect and it works just fine! Go back up and keep playing with the simulation. Compare how the green and the gray boat react to the circle pushing. Take a look to the vector lines drawn over the green boat, there is the direction and linear velocity in white and the Lateral Velocity as green.

My plans are to make a game out of this. Next step: oars. If you like it, keep tuned.

EXTRA HINT: Applying the lateral friction force not in the center of mass, but a bit behind, it makes a feeling that the boat is less resistance on its front part, the bow. Good also for simulating arrows or bullets 😉


Popular Today

  • Free Lowpoly Donald Trump 3D CharacterFree Lowpoly Donald Trump 3D Character Lowpoly Donald Trump 3D Character is a minimalist artistic representation inspired by the most relevant features of the real person. Rigged in 3ds Max and ready to use for animations and games. Includes FBX format and Unity Demo. Brought for you, by me, for FREE download using Creative Commons Attribution…
  • Symmetry Fix Algorithm for 3D MeshesSymmetry Fix Algorithm for 3D Meshes Not founding an existing solution on my case (3ds Max + MaxScript) I have "invented" (On the internet everything is already invented if you search enough, I didn't search enough) an algorithm to fix a 3D mesh that some of it's vertices went out of symmetry. The problem Imagine we…
  • Donald Trump High Quality 3D Caricature (Free Promotion ENDED)Donald Trump High Quality 3D Caricature (Free… Many people are saying, this is the best 3D Trump caricature of the Internet. Believe me.  After 2 years on  TurboSquid it has more downloads than any other president ever, specially Obama. Winning bigly! Today on CyberMonday we're going to make Trump 3D Model free. Denys is tired of winning, he's a…

Leave a Reply