- Home /
How to create an aura with selective collision detection
I have a prefab that I want to generate an invisible aura that only instances of the prefab can detect.
I'm thinking of adding a flattened sphere trigger body to the prefab, but is there a way to have it only interact with other prefabs?
Answer by kromenak · Feb 22, 2011 at 07:40 AM
You could use the layers feature of Unity for this (located at Edit > Project Settings > Tags).
If you create a layer called "Aura1", for example, and then put all instances of that aura prefab in that layer, you can then modify the Layer Collision Matrix (located at Edit > Project Settings > Physics) so that objects in that Aura layer only collide with other objects in that same layer.
Answer by Kona · Dec 19, 2010 at 06:35 PM
Do you mean that you want the objects/prefabs "aura" should only react if it collides with another object with the same aura?
I guess you could tag the aura-object/component with a tag like "aura" and then in your script check if the collider we collided with is taged "aura". And of course in case it is taged "aura" perform your event, else return.