Triggering a spotlight

Hi everybody,

Just started working in Unity in an attempt to use it for designing interactive spaces. I’m trying to do a little test in which the player approaches an object and when he gets near a spotlight lights the object.

When the player leaves the object , the spotlight turns off.

Been trying to script this for hours but not quite getting it. Hope you can help me

Thanks

Hello!

you could use triggers :), when the user enter the trigger OnTriggerEnter() activate the spotlight and then he exits, deactivate it. OnTriggerExit()

hope it helps you out :wink:

thanks for the reply. I used the triggers but somehow nothing happens… no errors either which is ofc always a good thing but nothing else either

hello, this should be able to help you out :smile:
http://col000r.blogspot.com/2009/06/unity-triggers-and-colliders.html

hope it helps!

:wink: