Hi!
I have a question about OnTriggerEnter() callbacks.
I have a First Person Controller roaming around a city-like environment and I want to detect when it’s gone down particular streets. I am using OnTriggerEnter() attached to invisible cubes to let me know when this happens.
At first, things seem to be working OK because the triggers go off but then I wanted to know which particular cube is setting off the trigger so I print out the name of the cube. To my surprise, the name printed was not the cube I expected, which totally confused me.
I simplified the environment down to just two cubes and attached images that will hopefully make clear what I am describing: the green cube is called “1a” and the red cube is called “1b”. Regardless of which one I hit, it seems like both triggers are being invoked and the 1b cube is called first. I expected only the trigger for the cube that was hit would be invoked.
[10734-screen+shot+2013-05-06+at+3.15.49+pm.png|10734]
[10735-screen+shot+2013-05-06+at+3.16.21+pm.png|10735]
If you look at the message in the game area (upper right viewport), the “1a” and “1b” actually overwrite each other. The console area shows how both triggers are invoked.
Am I missing something simple here? Is there a way to have only the tigger that is actually triggered be invoked?
Thanks for any help! I’m a bit of a noob so if I’m doing this the hard way and there is a better way of doing it, I’m open to suggestions, as well!