tutorials/scripting/gdextension/gdextension_cpp_example #36
Replies: 21 comments 41 replies
-
Here is how to create Visual Studio solution to build, code and debug GDExtension |
Beta Was this translation helpful? Give feedback.
-
Quick correction... take out
|
Beta Was this translation helpful? Give feedback.
-
do i need my project to be inside GD extension for this to work? or do i have to repeat the same process in a different folder (for ex i want to have my project inside an external drive)? |
Beta Was this translation helpful? Give feedback.
-
How do I connect a signal from Godot(ex: area_entered) to my C++ source code? |
Beta Was this translation helpful? Give feedback.
-
Do I have to use the same compiler that was used to compile Godot? Or does GDExtension work with any C++ compiler? |
Beta Was this translation helpful? Give feedback.
-
Where is register_class called? It is not mentioned anywhere else in this page, except GDREGISTER_CLASS(GDExample) in register_types.cpp . |
Beta Was this translation helpful? Give feedback.
-
Running into an issue where .hpp files don't get created at all - been following the guide word for word for godot 4.3 linux and it has nothing on this at all. |
Beta Was this translation helpful? Give feedback.
-
What's the proper way to extend
|
Beta Was this translation helpful? Give feedback.
-
I've gone through this tutorial step by step a few times with different versions but I keep getting this error:
versions of godot I've tried
|
Beta Was this translation helpful? Give feedback.
-
Hi, I am having problems with the properties and the signal. I fully followed the tutorial and I get no errors and the sprite is moving according to the However, none of the properties or signals added in All properties of the parent nodes are shown in the inspector, however none of the new properties show up there. This is how my void GDExample::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_amplitude"), &GDExample::get_amplitude);
ClassDB::bind_method(D_METHOD("set_amplitude", "p_amplitude"), &GDExample::set_amplitude);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "amplitude"), "set_amplitude", "get_amplitude");
ClassDB::bind_method(D_METHOD("get_speed"), &GDExample::get_speed);
ClassDB::bind_method(D_METHOD("set_speed", "p_speed"), &GDExample::set_speed);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed", PROPERTY_HINT_RANGE, "0,20,0.01"), "set_speed", "get_speed");
ADD_SIGNAL(MethodInfo("position_changed", PropertyInfo(Variant::OBJECT, "node"), PropertyInfo(Variant::VECTOR2, "new_pos")));
} This is the info about my system and the version
Anyone have an idea what I am missing? |
Beta Was this translation helpful? Give feedback.
-
Hi, is there a way to hot-reload newly compiled changes made to a GDExtension source file? Currently, I have to close and re-open the editor in order for the changes to be visible. (macOS, C++) |
Beta Was this translation helpful? Give feedback.
-
If you are seeing scons failures like the below, make sure you do not only have Visual Studio Preview installed. Scons seems to have issues with the preview toolchain. Just install regular, non-preview, Visual Studio toolchain.
|
Beta Was this translation helpful? Give feedback.
-
i can't find the sprite2d.hpp header. |
Beta Was this translation helpful? Give feedback.
-
I don't understand why the code to move the sprite executes in the editor and not just when the scene is running. How do I change that? |
Beta Was this translation helpful? Give feedback.
-
Could someone explain when I need to use Ref<> in gdextensions and why? I was trying to generate a mesh using surfacetool in a gdextension, and I figured through trial and error that I needed to return a Ref instead of a Mesh for it to work. But I don't understand why, and I couldn't find resources explaining that. |
Beta Was this translation helpful? Give feedback.
-
I'm playing around with coding my own implementation of this hexagon system. ( www.redblobgames.com/grids/hexagons/ ) when implementing the QRS cube coordinate system, only the q and r values are to be stored. So they are implemented as full properties with setters and getters. However the s property only have a getter, it can't have a setter. Still, it should show as a property. Is there a procedure for this? Or is my only workaround to bind a get_s() function? Separate issue, but related. |
Beta Was this translation helpful? Give feedback.
-
When it says "Time to jump back into Godot." How does the project (or the |
Beta Was this translation helpful? Give feedback.
-
To avoid recompiling godot-cpp every time you build your GDExtension, add the argument Make sure to prebuild godot-cpp for all your build targets. |
Beta Was this translation helpful? Give feedback.
-
To select the target C++ language standard from the SConstruct file of your GDExtension, add the following lines before the last line of the example "SConstruct file we prepared" and adapt the standard as you like: env["CXXFLAGS"] = [
flag for flag in env.get("CXXFLAGS", [])
if not any(s in flag for s in ["/std:c++", "-std=c++"])
]
if env["platform"] == "windows":
env.Append(CXXFLAGS=["/std:c++20"])
else:
env.Append(CXXFLAGS=["-std=c++20"]) The initial clearing is needed to remove the hardcoded values which are added by |
Beta Was this translation helpful? Give feedback.
-
I always get this error and I do not know how to fix it.
Compiling godot-cpp |
Beta Was this translation helpful? Give feedback.
-
If Godot crashes/segfaults/core-dumps on quit it's a sign that your GDExtension is set to the wrong ModuleInitializationLevel. Godot's Main::cleanup() function deinitializes the extensions in batches at the appropriate initialization level while it is closing down its processes. For example, if your GDExtension has an AudioEffect class on an Audio Bus it must be set to the level MODULE_INITIALIZATION_LEVEL_SERVERS so that its destructor hasn't been unloaded by the time the AudioServer is deleted. goatchurchprime/two-voip-godot-4#49 (comment) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
tutorials/scripting/gdextension/gdextension_cpp_example
Introduction: The C++ bindings for GDExtension are built on top of the C GDExtension API and provide a nicer way to "extend" nodes and other built-in classes in Godot using C++. This new system all...
https://docs.godotengine.org/en/latest/tutorials/scripting/gdextension/gdextension_cpp_example.html
Beta Was this translation helpful? Give feedback.
All reactions