Hi there !
I just have a strange behavior in my project. I just want to instantiate n times a prefab. (here no problem).
But i have a different Behavior if i cast and store the result of Instantiate and if i don’t.
Barrel is a class attached to my prefab and i want to be able to access to Barrel methods afterwards.
Let’s see it :
public Barrel[] obj;
obj[0] = (Barrel)Instantiate (barrel, inst,Quaternion.identity);
obj[1] = (Barrel)Instantiate (barrel, inst,> Quaternion.identity);
Differs from
Instantiate (barrel, inst, Quaternion.identity);
Instantiate (barrel, inst, Quaternion.identity);
In fact, in the first case my second (and next) created object does not have any gravity and NavMesh aren’t working on them.
If i use the second syntax (without cast) it’s working well.
Do you have an idea why it’s acting like this ?
Thanks for your help !