Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | VarionDrakon |
GDScript:
var item - null
if randi() % 2 == 0
item = ItemClass.Instance()
add_child(item)
to C#?
Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | VarionDrakon |
GDScript:
var item - null
if randi() % 2 == 0
item = ItemClass.Instance()
add_child(item)
to C#?
Reply From: | zaksnet |
PackedScene item;
RandomNumberGenerator rnd = new RandomNumberGenerator();
var result = rnd.Randi();
if (result % 2 == 0){
item = (PackedScene) ResourceLoader.Load("PathToYourScene");
var inst = item.Instance();
AddChild(inst);
}
Unfortunately, this method did not help me, but I will note it as one of the ways, for posterity) Thank you for your help!)
VarionDrakon | 2021-02-13 18:18