There is always 2 kinds of developers when it comes to gaming: There is the Developer Developing the Games, and the Developer developing the tools. In this particular article we talk about the Game Engine Core technology, but we cover in more detail C# technologies – among them the Unity Engine.
C# Game Engines
In a previous post, we covered a bit of how Lua Game Engines work at the core. But without a doubt the world today is dominated by the likes of technologies like Unity Game Engine – which has a portfolio of hits across multiple platforms (Established consoles, Mobile (Android / iOS), Web, Desktop, etc). Unity is behind Game Hits like the recent Fall Guys.
Disclaimer: Inspiration for this article comes from MonoGame – an Open Source C# Game Engine that is similar in some ways to Unity as a Core Engine.
What is the difference between how Lua works and how C# Works?
There are 2 I can say major preferences on Languages when it comes to Languages folks use to develop Games – these include – Lua and C#. Personally I believe C# has gotten prominence mostly due to the fact that Unity is quite a popular IDE / Tool, Lua is a veteran in this space. So what is the difference between these 2 languages when it comes to Architecture at the core?
In principle how C# is not so different from Lua in terms of how it technically works. The only difference is that the rift or divide between what is on C++ on the core and what is the high level C++ is huge – very huge when dealing with C#. Lua is designed to be like a more high level sibling of C++.
With C#, the C++ core is very much very well architectured and compiled to libraries even before C# touches any functionality coded on it.
Visual Architecture of C# Engines
As we can see, the C++ code is fully compiled into objects. That however does not mean these libraries solely originate from C++, other languages capable of compiling libraries can also take part in forming these libraries that C# can consume.
Integration with Low Level C++ (and other..) Binaries
The libraries are of 2 kinds:
- Platform independent – in which for instance a .dll can work on any platform.
- Or, platform specific dynamic libraries are compiled. These are mostly:
- .so files for Linux.
- .dll files for Windows.
- .dylib files for Mac.
C# has very established methods to bind into these dynamic libraries, and what Game Engine Core Developers do is they create Class Abstractions for how these Libraries are accessed, and they expose these Abstractions to the Game Developer. In essence, they are mostly taking advantage of very established Low Level Libraries compiled from C++.
Unity – and how their Eco-System is structured
In relation to the Core Engine that is C# – Unity went a step further and provided “add on tools” on top of the Engine Core, which comprises of the IDE / Unity Development Environment we all see, and the Products they offer as value add products / services. The Development Environment and these extra products allows you to use a number of tools and products they offer as part of the development experience you get, and they place it on top of the Game Engine Core. But they all blend so well to form one large Eco-System called Unity Game Engine – and provide powerful Game Development Experiences. Unity therefore goes a step further:
So in essence, Game Code, together with Plugins and Extensions, and Developer Tools, all work together to produce Game Binaries. These Game Binaries then have functionality embedded to access addon Unity Functionalities through its Product Offering to provide a single breathtaking experience that is not just provided with the binary – but with the eco-system. These include: Multiplayer support, CDN support, Advertising and Monetization, etc etc.
The choice to use C# to abstract a lot of the core functionality for C++ and other very low level binary implementation of logic seems to be a very smart choice. C# as a language is very focused on providing the best interface for Object Oriented programmers, and since most entities are represented as Game Objects, it does a much better job compared to very many other programming language.
And it has an extra advantage – being built on top of the Mono Framework, C# is built to be cross platform. Its implementation is also as efficient as technologies like Java, C# and Mono tend to be very close to bare metal and native in implementation. I believe there is a lot of scope for C# and how it will scale. There is more to come.