![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
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