GDScript to C#

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By VarionDrakon


	var item - null

	if randi() % 2 == 0
	item = ItemClass.Instance()

to C#?

:bust_in_silhouette: 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();

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