So now lets say i would like to acess the instantiated game object in the else if statement, How do i go about doing that? I’ve looked through some documentation but i cannot figure out how.
if(equipped){
// do this
}else{
// removed implicit cast, not necessary when “as” casting
GameObject item = Instantiate(inventory[selected], transform.parent.position, transform.parent.rotation) as GameObject;
// access instantiated object using variable to which you assigned it
item.name = “SomeName”;
DoStuff(item);
}