- Home /
Detect if player is inside a lighting arc?
I have a security camera giving off a light with an arc of 15. How can I detect if the player is touching the lighting arc?
Answer by Iceo MK · Nov 11, 2013 at 04:53 AM
I'm not sure if this'd work, but here's my approach to it.
Add a cone, make it Is Trigger (a checkbox in the Inspector view under Collider) Remove the Mesh Renderer
Then add a script to it that has a boolean variable which becomes True and a function that is OnTriggerEnter.
As soon as he enters that trigger, the boolean turns true.
This way you can use that boolean in another script you have to check if it's true or false, and act accordingly based on what your game does.
Not that my saying this is going to make it any more likely to happen, but Unity should have a cone primitive collider; I can think of several times where I could have really used one. (Both for a trigger and just a collider collider.)
the problem with that is the player will collide with the trigger collider even when hidden behind objects. use raycast ins$$anonymous$$d.
Your answer
Follow this Question
Related Questions
How to combine sprites to create a seamless and efficient level 0 Answers
Boo & Collision 1 Answer
Light touches Object 1 Answer
Light passing through mesh 2 Answers
Changing parent on collision 1 Answer