Question by
jbizzy129 · Jun 10, 2017 at 10:13 AM ·
c#movementrigidbody2d
Check whether a group of instantiated 2D rigid bodies are moving
I know how to instantiate objects using a array. My question is how can you tell if more than one of the objects you have instantiated is moving? Say I used player[i] . Assuming I instantiate 5 objects which are 2d rigid bodies what piece of code can I use to test whether or not these individual are moving. I use C sharp.
Comment
Answer by Bill9009 · Jun 10, 2017 at 10:40 AM
if(r2DgameObject[i].GetComponent<Rigidbody2D>().velocity != Vector3.zero)
This wiil show if a gameObject is moving. Remember to replace "i" with the index of the gameObject you want to check.