GDNative: Access other Node variables and change during instancing

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jayanthl
void PlayerController::spawn_bullet(Vector3 position, Vector3 direction, int speed) {
    ResourceLoader *resource_loader = ResourceLoader::get_singleton();
    Ref<PackedScene> res = resource_loader->load("res://ModelScenes/Bullet.tscn");
    KinematicBody *body = (KinematicBody *) res -> instance();
    body -> set_translation(get_transform().origin + position);
   // set direction variable defined other node object (c++ code variable) 
    get_parent() ->add_child(body)}

}

How can i access variable in the other object which i am instancing,

in GDScript it is
var node = bullet.instance()
node.direction = Vector3(1, 0, 0) // this is what i am talking about!
add_child(node)

How can i do this with GDNative C++ ?

Thank you in advance :slight_smile:

:bust_in_silhouette: Reply From: jayanthl

Got solution

used body → set(“bullet_direction”, Vector3(1, 0, 0));