+1 vote

enter image description here

I want to create a C++ Script And this is how I created it

Now when I created it, then I get this error

enter image description here

How do I solve this?

in Engine by (194 points)
edited by

2 Answers

+4 votes

You can't code directly in C++. However, there are 2 ways of using C++ in Godot:
1. Custom modules.
2. GDNative.
As writing custom modules is meant for adding functionality to the engine hence it's advanced, the most fit way to code game play would be GDNative in the form of a library.
So, here's the workflow with GDNative:

  1. You write your cpp/h files in an external IDE (like MSVS). The cpp has additionally code for registering classes and methods to be used in Godot.

  2. Build them into dll's (Windows) / so's (Linux). To do this you have to download
    cpp bindings and Godot headers.

  3. In Godot you create a GDNativeLibrary (on disk it has gdnlib extension).

  4. In Godot you create a NativeScript (on disk it has gdns extension). This has to be based on the gdnlib above.

  5. In the node you want the C++ functionality, you create a regular GDScript and you call the registered methods from within there, like you'd call methods from any dll native library.

GDNative is still work in progress and there are no straightforward tutorials on it but Readme.md from cpp bindings is a good start.

by (53 points)

Would it be this complicated int he future, as you said GDNative is still work in progress?

If I'm not mistaken I've seen changes on the GDNative C++ part like complicated method calling i.e. gdn.call_native("standard_varcall", "some_test_procedure", []) for calling some_test_procedure(), getting slimmed down to just calling f.i.cppClass.some_test_procedure().
I'm expecting improvements even further but I don't know how further.
For more info on C++ coding in Godot check these out:
http://godotengine.org/qa/16746/will-c-ever-be-built-into-godot?show=16746#q16746

http://godotdevelopers.org/forum/discussion/18806/is-there-a-simple-way-to-code-in-c-at-least-in-the-near-future

https://godotdevelopers.org/forum/discussion/comment/20466/#Comment_20466

Thank you for your help.

You're welcome. After a while, if you won't receive any more answers, please consider voting/accepting the answer. You can revert at any time :)

I voted the answer :)

0 votes

You have a lot of possibilitys to use native Code in Godot Engine!
I've made some videos about this topic, and collected the most important once here in my Steam guide :)

https://steamcommunity.com/sharedfiles/filedetails/?id=1972769090
enter image description here

by (128 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.