- Home /
Raycasting and Triggers Issue
Hi, so I'm making a 2D RPG, and I'm working with enemy AI. I have a LookAt function using raycasts that works fine, however, I need to modify this by going to Edit > Project Settings > Physics2D > Unchecking "Raycasts Hit Triggers".
Now what happens is that now my enemies can look through objects that are triggers, HOWEVER, I have items that you can pick up from OnMouseDown that are triggers, and apparently any OnMouse() function will not work if I have an item that's a trigger if I uncheck raycasting hitting triggers. I saw something about layers as an idea but that will not work because I require items that are weapons as triggers, so that cannot work.
Any ideas?
Answer by Pawscal · May 16, 2014 at 12:40 AM
You could use Layers to tells what kind of object your raycast should ignore Ennemies on one layer pickables on another etc...
Look at the section "Casting Rays Selectively" on this page: http://docs.unity3d.com/Documentation/Components/Layers.html
Hope it helps!
Your answer
Follow this Question
Related Questions
Can't click gameobject when over another trigger? 1 Answer
How to Find Owner of a Trigger? 1 Answer
OnMouseOver with multiple colliders 1 Answer
active script from distance 3 Answers
Multiple objects with OnMouseDown 2 Answers