Yes, Godot supports C++. While Godot's primary scripting language is GDScript, which is designed to be easy to pick up for beginners, the engine also supports several other languages for scripting, one of which is C++.
Godot provides a way to write game logic in C++ through a feature called GDNative. GDNative allows users to load compiled C++ code as a native script. This can lead to performance benefits and give developers access to all features and optimizations their C++ compilers provide.
Here's how you might typically set up a C++ project to work with Godot using GDNative:
Setup a C++ Project: Create your C++ project structure with source files and a SConstruct file if you are using SCons as your build system.
Write Your Code: Write your C++ classes, inheriting from
godot::GodotScript<T> where T is the type of Node that you want to extend (for instance,
godot::GodotScript<godot::Sprite> to create a custom sprite class).
Compile Your Code: Compile your C++ code into a shared library (
.dll on Windows,
.so on Linux, or
.dylib on macOS).
Create GDNative Scripts: In your Godot project, create .gdns files that point to the compiled libraries and use the native scripts as you would typically use a GDScript.
Attach GDNative Scripts to Nodes: Attach the
.gdns files to nodes in your scene.
By following this process, you can develop parts or all of your application in C++ while still taking advantage of Godot's engine features. It is important to note that interfacing with the engine this way is more complex than using GDScript and not typically recommended for beginners. However, it allows for high-performance code and the use of external C++ libraries in your Godot project, which can be critical for certain applications.