skip to content
Mythfallen

Getting the basics going

A rough idea of what I've done and what is ahead.

At this stage of development I’m focused on getting fundamentals in place. When you start a survival game, you need to typically:

  • Gather some rocks, sticks
  • Find some food
  • Build a campfire
  • Build some kind of shelter

There’s actually quite a lot in that, but getting it all set is my current goal. From this foundation would be a mini game all on it’s own, albeit limited in scope! Before I get into that however, I want to talk a bit about Save/Load concepts. This was an important goal of mine, and I’m pleased I’ve got a fairly good setup in place. I now have in place basic game saves and loads, in that I can restore the state of things, like player stats and position. The fundamental of my game saving is that I only want to load what I need to load. The fact that a chest has been opened half the world away isn’t important to load until I’m near it. That underpins my idea of save system. Items request their state when they are loaded by Unity and emit change for the Save system to track. I feel pretty happy with how this is working so far. Inventories were slightly different. The engine I am using comes with an inventory system but it has it’s own serialization methods. My first pass at patching this was way overcomplicated and buggy, but in the end I removed it all was able to inherit the inventory and create a child that just implements it’s own save and load. Those save and load methods don’t exactly align with the flow of my game, so I also emit change to my Save system so that when an actual save happens, I can persist it in my own way. Another key thing with Unity is it doesn’t expose unique IDs for game objects that persist between sessions. So chest A in scene A might be id 1 in one session, and id 2 in another. This seems like a common ask and I did find a unity blog and code to help achieve this. I took that and just added an extension method to GameObject so I can access the id more easily.

In line with the above, I’ve built the concept of a harvestable item - just a tree so far. You hit it a couple of times, it spawns some logs which you can loot from the ground. It also swaps sprites to a stump and that state is saved when you load your game. The code isn’t specific to a tree at all so it should be good for other harvestable things like rocks or a bush.

In the previous blog I mentioned about building storage chests. I’ve got this all working now, but it felt a bit more difficult than expected. The engine inventory system is very much geared to named inventorys and a given UI display mapping to that. It took a bit of deep diving into the system to make a display be dynamic in what it shows. It works though and it helped me understand the inventory system more. Later I’ll want a vendor system and can leverage some of this work there I think.

Finally, I’ve started having a go at pixel art. I’m using aseprite and I’ve been trawling YouTube for guides and such (Pixel Pete is great). I honestly have no idea if I can do the art well enough for a game I could release, but I’m really enjoying the journey. A good friend of mine is having a go too and between us I think what we have is looking alright. Of course, all of it can be replaced and if needed, I’ll pay someone with actual talent to do it! So far we’ve got some trees, stumps, a chest and an animated campfire. Hopefully in the next blog (or soon…) I will include some screenshots too.

That’s all, thanks!