- Home /
Selective Collision - Again
Hello,
I know this subject has been discussed here a bunch of times already. But I'm stuck here.
I am developing a simple game where I have a few rigid bodies piled and a projectile is intended to hit those gameObjects.
But some of those rigid bodies are collectibles, elements that give points if hit with the projectile.
My question is: I need those collectibles to behave just like the other rigid bodies, but as a trigger for the projectile.
How can I do it?
Regards.
Answer by Bunny83 · Sep 15, 2012 at 02:28 AM
It doesn't need to be a trigger. A "normal" collider also get messages(OnCollisionEnter, OnCollisionExit, OnCollisionStay) send. The only difference between a collider and a trigger is that a trigger can't "collide", so the objects don't get stuck on it and the messages on a trigger are OnTriggerEnter, OnTriggerExit and OnTriggerStay.
So all you have to so is write a script which you can attach to your collectible objects which react to OnCollisionEnter. Another way would be to give those objects a special tag and check the collision on the projectile. Just compare the tag of the hitted object. If you need an example, tell us your language (of course the programming language ;) ) you're using.