Multiple Instantiate : gravity does not apply to clones

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 !

You need to instantiate it as Rigidbody.

//Rigidbody allows gameObject to react with the Unity Physics Engine
Rigidbody myPrefab ;

var myPrefabClone = Instantiate(myPrefab , transform.position , transform.rotation) as Rigidbody ;

Hmm, the RigidBody isn’t intantiated if i instantiate it as a GameObject ?

And afterwards how do i use the methods of my class ? Doing a GetCOmponent on my RigidBody.parent ?

Edit : Just tried your solution, the behavior is exactly the same with a RIgidBody.