This page is part of the Essential Series modding tutorials. A Trigger (TRIG) is an entity asset that creates a region (volume) in the world. This region can detect if other entity assets (including the player) are inside or outside of it, with events for all of these cases. Triggers are never visible and cannot move. They are used all the time in the game to send all sorts of events when the player or other objects are in certain positions. TRIGs are usually found in the Default layer of the level's HIP.
Industrial Park has three trigger templates: one for sphere triggers, one for box triggers and one for cylinder triggers. You can also change the type of an already placed trigger, but this can result in a glitchy trigger (if you really need to change the type of an existing trigger, I would recommend placing a new trigger, copying over the links and the name and deleting the original one).
These are the simplest trigger type. Once placed, you can use the Asset Data Editor or the Gizmos to choose the trigger's position and radius. Sphere triggers cannot be rotated (spheres look the same no matter how you rotate them!)
Placing box triggers can be a bit tricky at first, but it's simple when you get the hang of it. When you select the Position Gizmo for a box triggers, a total of 9 gizmos will show up: six for the six faces of the box and three for the position of the origin point.
Moving the faces of the box is simple: you use the 6 arrows to choose their boundaries. It is only needed to move the origin point if you want to rotate the trigger: the box will rotate around the origin point, not around itself as most other objects do. This is why the rotation might seem a bit crazy at first!
Similarly to sphere triggers, cylinders have a radius and a height. Unfortunately, you cannot rotate cylinder triggers (they will behave as if they were not rotated). They were not used in the original game, but behave normally.
All events are sent to the trigger by the objects that enter or exit their volumes.
- EnterPlayer: sent to the trigger by the PLYR asset when it enters its volume. Note: this is not sent if the player begins the level already inside the trigger.
- ExitPlayer: sent to the trigger by the PLYR asset when it exits its volume.
- TouchPlayer: similar to EnterPlayer, but EnterPlayer is only sent once: if the player enters the trigger, they must leave and enter again for EnterPlayer to be fired again. TouchPlayer is fired constantly (once per frame) when the player is in the trigger.
- EnterEntity: sent to the trigger by any entity asset, such as a PLAT or a BOUL, when it enters its volume.
- ExitEntity: sent to the trigger by entity assets when it exits its volume.
- EnterSpongeBob, EnterPatrick, EnterSandy, ExitSpongeBob, ExitPatrick, ExitSandy: similar to EnterPlayer and ExitPlayer, but only sent when the player is the specified character.
- EnterCruise and ExitCruise: similar to the ones above, but sent by the Cruise Bubble.
Other events commonly used with triggers are Enable and Disable. The EnabledOnStart and Persistent flags (explained in the Dispatchers page) are useful with triggers, because a disabled trigger does not send any events, and many times we want triggers to only function in some conditions.
A simple use case of this: you want to make a race against a timer. At the finish point, use two triggers: one which causes the player to win the race, and one which causes the player to lose it. Normally, both start disabled. When the race's timer starts, the win trigger is enabled. When the timer expires, it means the player lost. At this point, the win trigger should be disabled and the lose trigger enabled.
Source Check is a field present in every link and editable in the Link List Editor. This field is usually empty, but it works on any link, and is specially useful with triggers and the EnterEntity and ExitEntity events. This is because the Source Check filters which asset will trigger that link; the event will only be sent if the asset which sent it matches the Source Check. For example:
- Trigger TRIGGER_01 has a link which is EnterEntity => Run => TIMER_01, with nothing in the source check.
- The same trigger also has a link which is EnterEntity => Run => TIMER_02, with BUBBLEBOWL in the source check. (BUBBLEBOWL is the asset ID of the BOUL asset that makes SpongeBob's bubble bowl)
Ingame, a moving platform enters the trigger. This will cause TIMER_01 to run, as an entity has entered the trigger, but not TIMER_02, as the entity does not match the source check. When SpongeBob throws the bubble bowl at the trigger, both TIMER_01 and TIMER_02 will run, as an entity has entered the trigger and it matches the source check for the second link.