KlaxEngine was the result of my bachelor thesis. The goal was to create a game engine including an editor application with which the user would be able to quickly script the logic for small game prototypes.

The engine is written in C# and features a DirectX-based 3D renderer which supports shadows, a third party physics system, an asset manager, levels, a visual scripting language and an editor to access it all. The editor application is written using the WPF framework.

Development time: 4 months (October 2018-January 2019)
Roles: Programming, Editor Visual Design
Language: C#

The engine was written in close collaboration with Henning Ax
You can download the project here: Github Repository

Motivation & Editor

Since this project was part of a bachelor thesis, we had to pick our battles when it came to scope.

We definitely wanted to implement a scripting language of some sorts and initially we still planned this language to be an implementation of LUA. During development it became apparent though that a visual scripting language in the style of Unreal Engine's Blueprints or CryEngine's Schematyc would be a more appropriate (and admittedly more exciting) solution.

During our internship at Envision Entertainment where we were both working as tools programmer, we learned how to utilize the WPF framework for applications. While the decision to use this framework for the engine editor limited us to the Windows operating system, we still had to pick our battles and came to the conclusion that Windows is the primary game development platform anyway. That way we did not have to invest time into learning another cross-platform framework like Qt and could focus more on the actual content of the engine and editor.

Visual Scripting - KlaxScript

The most polished part of the engine was our own visual scripting system called KlaxScript. It was heavily inspired by Unreal Engine's Blueprints and Crytek's counterpart Schematyc. It allows the creation of game logic without recompilation and is entirely data-driven. The included features are:

  • Functions, events (calls from code to data graph), variables, scoped variables
  • Containers of all exposed types (List, Dictionary)
  • Cross-entity communication
  • Pure nodes (equivalent to constness in C++)
  • Automatic C# code parsing (using attributes)
  • Dynamic nodes (e.g. switch statement that can change input and output pins depending on type)
  • A lot of common functions already exposed (math, material parameters, entity interaction, spawning, string manipulation and more)
  • Context-aware node suggestions (e.g. suggesting only nodes that take a float input when dragging out a float output pin)
  • Copy-paste
  • Undo-redo

There are two modes in which KlaxScript can execute node graphs.
The first one is used while working and playing in the editor and makes use of reflection to invoke the native C# functions behind nodes.
The second mode parses the exposed functions and variables once in the beginning of the game's lifetime and generates a new .NET IL assembly. When invoking a node, that node in turn invokes a delegate pointing to a wrapper function in that newly generated assembly and avoids the performance overhead of the reflection system. Generating the assembly takes only a few milliseconds and results in a 4 times higher execution speed.

In addition to that KlaxScript acts as the engines' prefab system. KlaxScript entities can be instantiated within a level by simply dragging them from the asset browser into the viewport.