Can I merge Gdscript and C code in the same project?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fcruz

Im new in godots engine and i would like know if is possible merge GDSCRIPT and C Code, for example, create a SQL login/register in C and later go to the game scene programed in GDSRIPT.
Another example, create something in GDSCRIPT, that can interact with something created in code C.

If is possible, please tell me how i can do it for a future project.

Thanks and regards

:bust_in_silhouette: Reply From: chanon

Yes, you can definitely do that. You can either create a GDNative module, or a normal C++ module.

The API in the C++ side is practically almost the same as in GDScript (actually it is a superset since not all methods are exposed to GDScript), so it is somewhat easy to learn.

Normal C++ modules are the original and stable approach for adding custom C/C++ code to your game. GDNative is still very new.

Go through the whole “Engine development” section to get a good overview for working with the engine code:

See the “compiling” section so you are able to compile your custom modules:

Take a look at this for custom C++ module development:

Or for GDNative there is this example: