0 votes

i have an instance

MAGIC_BLAST = loader-> load ("res: //Nodes/Player/Magic/Magic_Blast.tscn", "PackedScene");

Node2D * magic_blast = cast_to <Node2D> (MAGIC_BLAST-> instance ());

in gdscript it would look like this magic_blast.set_magic_blast_direction(1)
but I don't know how to get a method from this instance in C ++

in Engine by (29 points)
MAGIC_BLAST = loader-> load ("res: //Nodes/Player/Magic/Magic_Blast.tscn", "PackedScene");

Node2D * magic_blast = cast_to <Node2D> (MAGIC_BLAST-> instance ());

Take notice that the function is in CamelCase

I just looked in Google and found out what CameCase is, but I didn't understand you a little

This is C++, not C#.

1 Answer

+1 vote
Best answer
// Call by name
magic_blast->call( "set_magic_blast_direction", Array::make(1) );

// or, if your magic_blast is C++ class
CMagicBlast * magic_blast = cast_to <CMagicBlast> (MAGIC_BLAST-> instance ());
magic_blast->set_magic_blast_direction(1); // Normal C++ call
by (1,438 points)
selected by

such a question, did you learn all this by reading libraries like Node2D.hpp? there is simply no normal documentation for gdn C ++, you often save me dude

Well, gdnative requires kind of both experience in Godot and C++.
If you have this, it's not that hard to figure out. And although C++ documentation is almost non-existent, most of C++ API is reflection of GDScript.

There are some quirks, but than can be googled :-)

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.