Skip to content

Latest commit

 

History

History
114 lines (93 loc) · 6.92 KB

index.md

File metadata and controls

114 lines (93 loc) · 6.92 KB

Scripting Games

Scripting

The most important part of every game are Scripts. Creating chunks of code that handle game events, respond to user input, and control objects is an essential ingredient in all games. In short, scripts make games interactive by adding gameplay. It applies to both small and huge production. This documentation section covers the most important parts of the scripting pipeline and helps with starting the game programming.

Flax supports C#, C++ and Visual scripting. The mix of those three languages is highly integrated into the engine as it's written in those languages (engine is C++, editor is C#).

Note

Explaining C#, C++ and vector math is out of the scope of this documentation.

Code Modules

Important concepts related to programming in Flax are binary modules. Binary modules are compiled source code libraries that can reference other modules (eg. Editor, Graphics, or plugins).

In most cases, the main game code is in the module named <project_name> or named Game located in Source folder (eg. Source/Game). That's the place where you can add new scripts so build tool will compile them. For more, advanced uses game can contain multiple modules and have code split for better organization (as for example engine does - it's made of multiple modules working together). For instance, you can create an editor-only module and use its code only in the Editor.

To learn more about build tools and infrastructure see Flax.Build utility documentation.

C# Scripting

You can write scripts in C# and add them to scene objects. To learn more about it see the pages in this section. Most of the documentation related to scripting covers C# to implement various gameplay logic. If you need help with learning C# see this page.

Flax uses .NET to load, compile and execute C# scripts. Currently the newest C# 12 version is fully supported. Flax Editor requires .NET SDK 8 to be installed on a system.

If you want to use custom .NET libraries use build scripts to reference them as shown here.

C++ Scripting

Flax supports native C++ scripting with direct access to whole engine API. C++ scripts can be created side-by-side with C# scripts and expose own types/functions/properties via automatic bindings as decscribed here. To write and use C++ code engine headers and platform toolset are requried.

To start native scripting in C++ see the related documentation here.

Visual Scripting

Flax supports Visual scripting with fully-featured Editor tools for creating, using and debugging Visual Scripts. Visual Scripts can inherit from C++ or C# classes (eg. custom Actor or Script) to provide more logic and data. Visual Scripting is very light-weight and extensible solution for prototyping games especially boosting the rapid development.

Visual Scripts can access to whole engine API and the game code. Visual Scripts can be created side-by-side with C# and C++ scripts to expose own functions/properties. Also, Visual Scripting doesn't requrie any additional tools nor compiler as it's hot-reloading in Editor without any processing to provide even more robust development.

To start visual scripting see the related documentation here.

In this section