I was wondering, in Unity 3D, how I could do something with the Spot Light (Range/cone) as a trigger? Since it would be very interesting to be able to manipulate whats actually in sight of Light range/cone, and then trigger an event / method.

Example of the Spot Light (Range/cone)

Spot Light Range Cone

Since i'm at a Game Jam right now, I don't have infinite time, so some help or atlest thoughts on this, would be very much appreciated.

  • \$\begingroup\$ Is it going to be 2D? if so you could simple check if an object is within the light cone by comparing the angle. \$\endgroup\$ – Sidar Oct 5 '13 at 7:06
  • \$\begingroup\$ No it's gonna be 3D, so I need full flexiblity. \$\endgroup\$ – Kevin Jensen Petersen Oct 5 '13 at 7:35

I'm not sure, but in Unity the surefire approach to anything tends to follow this pattern:

  1. Create an empty GameObject.
  2. Create a cone shaped collider and set as a trigger, e.g. using something like this: http://wiki.unity3d.com/index.php?title=CreateCone
  3. Move the spotlight and collider under the GameObject.
  4. Put a script on the GameObject which allows changing the range etc, possibly by scaling the collider or possibly by re-generating the mesh.
  5. Moving/rotating should work fine because you always move/rotate the parent GameObject.
| improve this answer | |
  • \$\begingroup\$ I see.. That was just what I needed. An insight into how to make such thing. I appreciate it mate. \$\endgroup\$ – Kevin Jensen Petersen Oct 5 '13 at 11:46
  • \$\begingroup\$ No problems. Sometimes the Unity mindset takes a while to get. \$\endgroup\$ – David Cummins Oct 6 '13 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.