2
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\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, 2013 at 7:06
  • \$\begingroup\$ No it's gonna be 3D, so I need full flexiblity. \$\endgroup\$ Oct 5, 2013 at 7:35

1 Answer 1

3
\$\begingroup\$

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.
\$\endgroup\$
2
  • \$\begingroup\$ I see.. That was just what I needed. An insight into how to make such thing. I appreciate it mate. \$\endgroup\$ Oct 5, 2013 at 11:46
  • \$\begingroup\$ No problems. Sometimes the Unity mindset takes a while to get. \$\endgroup\$ Oct 6, 2013 at 4:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .