If I want to trigger a series of events when the character enters a trigger, is there a way to use only 1 trigger or should I work with multiple triggers each on the same spot?
I have a room that is divided in several zones. When the player enters a zone, the corresponding videoclip starts playing on a screen in the room and lights switch on and change color, also some of the lights of the previous zone switch off.
How can I tackle this in a nice way ?
Define a bounding box for the zone, add OnTrigger, and keep references to all objects that need to be activated in a script that will be attached to the gameobject with the bounding box.
When the trigger triggers iterate through all the objects and activate them.
Possible also have references to all other zones, so you can send a message to them that they should deactivate their objects.
Yeah. Use multiple triggers, each one handling its own business using OnTriggerEnter() and maybe OnTriggerExit(). It would probably be as simple as:
function OnTriggerEnter()
{
Lights(false);
lightSet = lightSets[2];
Lights(true);
StopVideo()
video = videos[2];
PlayVideo();
}
So, When the trigger is entered, Lights(false) turns off the active lights, reassigns the new zone’s lights as active, then turns them on with Lights(true). lightSets[ ] is an array of every zone’s lights. The trigger also shuts off the video that was playing, reassigns the current zone’s video, than starts playing it.
That’s just an example. There are probably many different ways of doing it, so design a system that works with your project, but multiple triggers (one for each zone) is the way to go.