–1 vote

I want to know how to create an instance with GDNative C++ I got no idea how to do it.

in Engine by (63 points)

An instance of what? A node instance? A scene instance? Do you know how to do it in GDScript to begin with? (I would recommend doing so before rushing C++ and GDNative)

yes I want to create a node instance and add it in as a child from a parent.

1 Answer

+1 vote

In GDScript:

# Creates a Sprite node and adds it as child of the node
# the current script is attached on
var node = Sprite.new()

In C++:

// I believe `new Sprite()` would not work, for reasons I don't remember
Sprite *node = Sprite::_new();
by (27,896 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.