- Home /
How to know if something is in the shadow
Hi everyone, For a game prototype i want to make something moving only on the shadow ( die when light for example)
i wanted to know if there is any possibility to know if an object is in the shadow or hit by light in the unity function?
there is also the way of making physics ray from light but if i had a lot of light it's going to be heavy.
if it's possible i want to use the function of the shadow manager of unity
thanks.
Answer by lance12367 · Mar 19, 2016 at 08:39 AM
Use the lookat with a raycast forward from the light to find if the ray will hit the player hope this helpz!!
Answer by devilsid · Mar 19, 2016 at 05:03 PM
You can use trigger colliders where the shadow is and perform your game functionality. I would suggest avoiding heavy calculations as you know it just tips and tricks that works in game development.
Yes that would help given that the light was not moving
Answer by Narines · Mar 20, 2016 at 03:14 AM
Hi !
The answer found in here might just be what you need.
http://answers.unity3d.com/questions/511419/how-can-i-detect-if-an-object-is-lit-by-a-specific.html
As gardian06 suggests, you can simply add a collider that covers the area covered by the light and detect collisions to know if the character is affected by the light or not.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Light artifacts 0 Answers
Shadow casting 1 Answer
How to make a GameObject not hittable by shadows ? 2 Answers
Solution for this shadow problems? 1 Answer