Reviving a 5 year old Unity 2D Sandbox Survival Game

Almost 5 years ago, I wrote a post giving a brief update on a 2D sandbox survival game I had been working on, Dropship.

I still don’t have any plans on releasing this, it is purely a creative outlet for me. But, I did just revive it from my Bitbucket repository and load it up into Unity to work on it a bit more.

The game is inspired by the likes of Starbound, Terraria and Minecraft.

New Features and Fixes

Loading it up again, I discovered I last used Unity 5.3 to work on this project. In terms of Unity editor versions, that is prehistoric! I did not want to hassle with script and asset deprecation issues, so I downloaded the latest Unity 5.3 editor version, and got stuck in.

Playing the game for half an hour, and noting down some annoyances, I worked on adding and fixing the following:

  • Lava and Water tiles now fuse together to form rock when touching. I had noticed that before they would just sit on top of eachother. Now the water will cool the lava and form rock in it’s place.
water and lava tiles combining into rock
  • Previously, you were unable to remove the background layer tiles once placed. This got annoying when constructing things. I updated the code to allow removal of the background layer with your construction tool. Left-click and hold removes the foreground layer, right-click does the background layer.
multiple layer deconstruction

In order to get this working I needed to modify the layer masks I use with Unity Physics for the raycasting, and needed to do some bitwise operations to dynamically modify masks on-the-fly due to differences between placing and removing objects.

  • Swimming! You can now swim in liquids. (Not that you would really want to take a hot lava bath though…)
2D Sandbox Survival Game - swimming added

Great if you drop down into a deep cenote, and need to swim back up to the surface.

I’m using the standard 2D character controller from Unity for movement, so it was a simple case of modifying this to add a ‘touching liquid’ check using Phyics2D.OverlapCircle() and then adding a case for controlling movement via updating the player rigidbody velocity manually when underwater (or lava!)

For gravity adjustment I set the player RigidBody2D’s gravityScale to 1/8th of normal gravity when underwater.

  • Fixed block placement around the character. Previously you could place objects in the foreground layer on top of yourself, resulting in weird physics issues like the player getting stuck inside blocks and then popping out uncontrollably. This was an easy fix to prevent the Player’s layer from being considered for block placement.
2D Sandbox Survival Game - block placement around player fixed

Moving Forward

Going forward I would still like to work on my 2D sandbox survival game. It’s a great creative outlet for me personally. I really enjoy adding new features and then actually playing the game.

I clearly spent a lot of time on the initial development as I’ve got a terrain chunking system, and complete serialization/deserialization system working that allows you to save and re-load your world.

Digging underground and crafting a secret base among the caves and lava flows is also a lot of fun!

Perhaps next I can work on adding better AI and enemies, and fully implement the survival needs system – energy, food, water, and maybe add a temperature system too.

Leave a Comment