Inspiration

My brother is a creative young engineer, and as a 6 year old, the best way to output his creativity is through his revered LEGO blocks. But he doesn't have too many of them - they're expensive and get lost easily. Everytime he wants to build a new project, he has to tear down the old one. What if he didn't have to go through all that trouble? What if he never had to step on a stray LEGO ever again? The experience and education is what matters, which is where Khelo comes in. Khelo means "play" in Hindi.

What it does

Khelo is a Unity built game designed to provide the LEGO building experience in a virtualized environment. The reason it is built in Unity is because the desktop application can easily be ported into Virtual Reality and Augmented Reality headsets to give a more immersive experience previously unavailable. Users can place blocks of different colors and types all across a wide building field. Users can also delete objects and support certain blocks in ways impossible in real life LEGOs, creating unique structures. In the upcoming HoloLens and VR models, the user can anchor their creation to a single point in the world and walk around the object as if it was really part of their universe. The user would be able to pick from a shelf of unlimited pieces to construct buildings, vehicles and creations unmatched by the current physical system.

How I built it

I used Unity's excellent C# game engine to construct the application. Each block is an actor that responds to block directors, allowing users to use blocks of different types, such as 1x1, 2x1 and 2x2 bricks. Each block has can place exactly one brick above it, keeping the game bounded to reality.

The saving/loading feature is built upon XML serialization. After creating a singleton XML manager, the user can save all the Khelo blocks into a XML file stored on their hard drive. This XML file is easily editable and very lightweight - each file is only a couple of kilobytes. This means the files can be saved in the cloud in the future. In fact, eventually users will be able to work on the same model through two different devices.

Challenges I ran into

The number one challenge I ran into proved to be the most rewarding experience. Saving files onto the user's computer in Unity isn't an easy task and requires system modification. I spent nearly 3 hours working on different serialization methods and eventually ran into XML serialization. Though it wasn't incredibly easy to implement, it proved immensely useful because of its lightweight nature and easy of readability.

Placing was surprisingly challenging. Because the blocks are different sizes, they have to respond differently. Because there will be hundreds of blocks in the final version, I couldn't create a robust system for each individual block. I spent around 1.5 hours on placing, eventually perfecting a flexible system that applies to any brick, tile or plate.

Performance was a major issue in the beginning. There were so many blocks that each had their own lighting conditions that lagged my computer so much, the game ran at ~11 FPS. I spent approximately an hour browsing through different profilers and methods to optimize the game, eventually running at a stunning ~50 FPS in full screen. There are more methods to improve the performance that I will be exploring.

Accomplishments that I'm proud of

The complex block actor/director system allowed me to let the user place blocks of multiple different types in a flexible format. I created the program to be flexible and allow any future type of block, including tiles and plates. By interacting with block actors, the program is flexible, but by incorporating block directors, the user can operate quickly and not waste time, making creation as fast online as in the real world. The placing system compliments the block actor/director system, adding more flexibility and potential to Khelo.

I'm most proud of the compact system I built for Khelo. Every script was written as concisely as possible, with comments and shortcuts for maximum optimization. The total project was written in only 694 lines of code.

What I learned

I learned multiple methods of serialization, such as binary format, text files, and XML. I eventually settled on XML serialization for ease of human readability.

I learned the different methods for code flexibility, and the importance of comments! With so many different classes and complex systems, writing comments for myself was a necessity. The actor/director system would have easily made me run in circles had I not written comments to describe the differences in interaction.

What's next for Khelo

The next step is to move Khelo beyond the desktop. The final vision for Khelo is for Microsoft HoloLens. As soon as I get home, I'll be porting the application to HoloLens and having my little brother create a variety of objects on his living room floor just like real LEGOs.

Built With

Share this project:

Updates