- Home /
30 Collisions with tags alone
I know we use On Collision Enter to see if the current object collides with another. However In my scene, their are 30 objects and I want to see for example if
Object1 is colliding with Object10
or Object20 is colliding with Object31
Can I use one script attached to a empty game object to see if two specific objects in my scene are colliding? Find object with tag?
It might be best to use a manager approach for this; store the objects in a centralized array which you sort as necssary.
Answer by judy3turn · May 01, 2013 at 01:44 AM
Find object with tag will return an array of objects that have that tag. You can iterate through the list. I'm not certain if there is an order in which the list is returned. If you're lucky and it's alphabetical and you don't mess up, you could use the index and then test for the collision between the objects of those two indices (1 and 10, or 20 and 31 in your examples).