Hi,
The first code requires pragma downcast (but works ingame), the second code does not give compiler warnings but throws a null reference error.
I rather don’t use pragma downcast but can;t figure out why the 2nd code does not find the rigidbody
// requires pragma downcast
var RigidBodyArray :Component[];
RigidBodyArray = gameObject.GetComponentsInChildren(Rigidbody);
for(var rbody :Rigidbody in RigidBodyArray)
{
DoStuff();
}
// Causes null references in game
var RigidBodyArray :Rigidbody[];
RigidBodyArray = gameObject.GetComponentsInChildren(Rigidbody) as Rigidbody[];
for(var rbody :Rigidbody in RigidBodyArray)
{
DoStuff();
}