- Home /
Detect Collisions from Script
Hello,
First post!
I've been teaching myself how to use Unity and all things involved, however, I am still a n00b. Scripting knowledge is limited, although I am constantly learning new things.
Which brings me to my question: How can I use a script to detect collisions between two other objects? Basically, if A and B collide, a script on object C detects this, and reacts accordingly. I can detect collisions between an object the script is attached to, and another particular object, just haven't figured out how to do this with two different objects I've set the GameObjects as variables in the script, aaaand thats about as far as I can go. I'm working in C#, although I could figure out a translation if need be. I've spent awhile searching forums and trusty Google, with no luck. I also like to know why things work (why this code does this etc), so I can then go on to figure stuff out, and make things work for me :)
Thanks in advance!
Answer by DaveA · Nov 14, 2011 at 10:47 PM
Generally you would detect collisions as you have, and if another script needs to know about it, you can call SendMessage to tell the other objects/scripts that collision has occurred.