Post news RSS Serialization Update in Chronus

Update on game progress, and serialization in Chronus.

Posted by on

Introduction
So for those uninitiated, a couple of weeks ago I mentioned that I would finish serialization in "a couple of days". As you can properly tell, that did not quite go as expected. What happened was I, once again, encountered some strange bugs with the serializer I was using, which lead me to abandoning it.

Unity Serializer - pros and cons. What I've learned from using it.
Once again, for those uninitiated I used a serializer called Unity Serializer which is supposed to simplify an otherwise quite complex feature. Even though I, at the time, had never worked with serialization, I knew that if I were to write my own code for serialization, it would take quite a while and properly not turn out great. I based this assumption off of previous experience with avoiding having to spend a lot of time writing code that someone else has written, a prime example would be the GUI API I'm using called Daikon Forge. It has increased the speed at which I develop UI by a tremendous amount, streamlining the development process of pretty much everything in the game. I, unfortunately, falsely assumed that I would have an equal amount of success with the serializer, but time would soon tell that it actually did the polar opposite, and merely costed me a ton of development time

Before I start my rant on why I regret using the Unity Serializer, it should be mentioned that it can be a great tool for certain things. If your game requires little to no serialization, it's definitely the way to go. You're not going to want to write your own serializer, if you're barely ever going to use it anyway. The problem with Chronus is that it requires a ton of serialization, since the player is building most of the content.

Furthermore, Unity Serializer is also very bad at handling prefabs instantiated at runtime. For some reason, these objects follow a different ruleset, which has caused me a ton of issues over the two-three weeks time I used it. After doing a bit of Google foo I encountered that most of my issues were indeed related to instantiation of prefabs during runtime.

Eventually I simply got fed up with all of the bugs I had no way of properly solving, and I decided on the day that I was supposed to release the first semi-stable build of Chronus, to ditch Unity Serializer and write my own code to Googles serializer called Protobuf, or more specifically the .NET compatible version called Protobuf-Net

Writing my code to serialize objects using Protobuf-Net
At first I was a bit nervous of this decision. I'm a fairly new programmer (Been programming for around 2-3 years now), and this would by far be one of the biggest challenges I've encountered. I knew from the get go that, unlike in Unity Serializer, Protobuf would not support Unity's classes (Primarily GameObject and Component), and as such I would have to write my own classes using .NET compatible types, cleverly naming them DE_GameObject and DE_Component (My name is Daniel Everland). My biggest fear was that I either would completely give up, or that the end product would turn out poorly.

As it turns out, this wasn't all that scary at all! I mean sure, everything was really complicated and tricky, but at least I was getting somewhere. This was my code and whenever a bug arose, I was able to quickly find a solution to it. During development with Unity Serializer each bug felt like a punch to the groin, but now they were more or less challenges I accepted with opened arms. Development of the serializer went quick, and I'm happy to announce that I'm almost done, 1 week after starting development of the serializer.

I sent the prototype to a friend a few days ago to test how well the serializer worked on his machine, and I was actually a bit surprised by the results. The test serialized 3000 gameobjects, which is far more than I expect anyone to ever need. It saved in 2 seconds and loaded in 1 minute. Loading time was a bit longer than I had hoped for, but it's worth mentioning that the system isn't optimized. With optimization the system should run incredibly smoothly. Fingers crossed.

When will 0.2 be released?
At the very latest it will come out in a week, however, I expect it to be released sometime around wednesday. At the moment serializing ships work completely, all I need to add support for is Special Cubes. Once that's done and I've polished and optimized it a wee bit it will be ready for release, hopefully with only a bit of maintenance in the future.

It should of course be noted that the file structure I mentioned in my previous entry will stay the same without any difference what so ever. I'm looking forward to the release of version 0.2, hopefully a few people reading this will as well.

- Daniel Everland

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

News
Browse
News
New
Post news
Share
Related Games
Chronus
Chronus Third Person Shooter
Related Engines
Unity
Unity Commercial