Is there a way to find all rigidbodys that are currently in the scene?
my scripts so far:
var AllRigidbodys[] = FindObjectsOfType(Rigidbody);
… it’s not working
can someone help?
Is there a way to find all rigidbodys that are currently in the scene?
my scripts so far:
var AllRigidbodys[] = FindObjectsOfType(Rigidbody);
… it’s not working
can someone help?
Remove the from after AllRigidbodys
var AllRigidbodys = FindObjectsOfType(Rigidbody);
You have an array of rigidbodies not a single one - so you need to loop over them. The array doesn't have a .gameObject - the members of the array do: for(var rb : Rigidbody in AllRigidbodys) { rb.AddExplosionForce(explosionForce); }
– whydoidoitSince you probably wish to define an array:
var AllRigidbodys : Rigidbody[] = GameObject.FindObjectsOfType(Rigidbody) as Rigidbody[];
That should work - what's happening?
– whydoidoit