Improbable Icon

Pirates Tutorial With Water Physics



When I started learn SpatialOS, I did a lot of changes to the pirates tutorial. In my game I plan to have sea battles and what else would be cooler than an ocean with waves and swells. After some testing, I was able to sync the waves from the server to the clients and in my opinion it works very well! It does make shooting pirates a lot harder though.

I use the Suimono Ocean asset for the water and waves.

Cool things happening right now with SpatialOS

Ah, I remember this being shared around a while back. Awesome stuff! :slight_smile:


That is exceptionally cool!

Was it a challenge to get it working? can you share how you did it?


First part of the challenge was figuring whether to load the ocean in an entity or leave it in the scene. I found out because of how complicated the ocean asset was, it was easier to spawn an entity that finds the ocean in the scene than try to package it all up.

After that, I just had to send out the wave timer to incoming clients in an entity state for syncing purposes. The waves are deterministic, I think, based on the timestep counter.

Since the ships didn’t have rigidbodies, I had to adjust there movement controller. The water asset has a bouncy example so after some experimentation I finally got all the ships staying on top of the water. It can probably be improved by adjusting the client wave timer for latency but it is good enough for now.