Creating Time (literally!)
I have a knack for forgetting what I’ve managed to accomplish on the game during the week. To try to overcome this so I have updates I can post on it, I’ve started writing down each accomplishment on a sticky note.
Read more...
Implementing a Thread-Safe Queue
One of the most useful data structures when it comes to multi-threading is the queue. However, queues in c# aren’t thread-safe by default. Thankfully it’s easy enough to implement your own as we will do today. Let’s start by defining our class.
Read more...
Playing Around at the Bit Level
This weeks adventure has been exploring object serialization. Initially I was using the serializable attribute to convert my objects into byte arrays but for some objects such as the voxel chunks this is far from ideal. Since I don’t want to handle serialization with 2 different methods I’ve decided to bite the bullet and roll my own set up.
Read more...
Building Up the Network Logic
While this week may not have much to show for it has built a solid foundation for networking. I spent some time refactoring the pre-existing network logic to try to clean things up. I really didn’t like how the NetServerManager and NetClientManager derived from a base class of NetManager that had a NetMessageProcessor component. It was gross having to call that and subscribe to it’s message events. I also didn’t care for how each message had it’s own event. To try to curtail this redundancy I came up with the following solution.
Read more...
Sometimes we want code that can run outside of Unity and that can make things tricky when it comes to writing text to console. Unity has it’s own set of methods for writing to it’s command console via the Debug class with the most commonly used one being Debug.Log(). However in the event you want to create a library of code that can be run within Unity or in the command console (say a game server for example) you’ll need a way to differentiate between the running environments. Instead of wrapping all our Debug.Log() calls in preprocessor directives such as #IF UNITY_EDITOR we can write a simple logging class to handle it for us. While we’re at it well add the ability to write log files since they can be quite useful.
Read more...
Stepping back into Networking
These past few months I’ve been on a tangent that wasn’t exactly planned. Diving head first into networking code, and attempting to refactor the voxel engine to support it really burnt me out. During this break I’ve been focusing on the core voxel engine itself. I decided to take the time to really spruce up the voxel engine and add in some much needed features. While I can’t exactly remember every change some of the key ones are:
Read more...
Creating new gameobjects during runtime can be a costly operation. Multiple this action by 10 or more times in a single frame and you’ll notice a slight hiccup in FPS. One option to counter this is by taking advantage of object pooling. Object pooling is when a collection of inactive gameobjects is kept on standby. When the game needs a new object it can call upon the pool to retrieve an already instantiated instance. Then when finished, the object can be returned back to the pool for later use.
Read more...
TL;DR Full algorithm is at the bottom. Classes for Block
, Chunk
, and MeshData
are defined below the intro.
This article goes over how to implement a greedy meshing algorithm for generating optimized meshes for vertex-colored voxels in Unity. The algorithm is derived from Robert O’Leary, with a few alterations made.
Read more...