The Reactor Component
Last updated
Last updated
The Reactor Component is best added onto it's own gameobject with a collider. This allows you to easily move the asset if need be, and this can be useful when the collider needs to be a child of an elevator (so the reactor moves with the platform).
This also makes things much easier to navigate, especially if you have a complicated scene.
You will also need to adda collider for the event to be triggered by. A box collider is best performance wise, but others are acceptable.
The Reactor Component is made up of several event types. Each one can hold multiple triggers.
An example would be if the player walks into a collider, 5 different Animators could trigger a specific animation. One trigger is the most common, however.
OnInteract - When the collider is targeted by the white reticle of the player, you can press the 'E' key to interact with it, which can trigger an animation. The OnInteract event also allows you to customise the text on the asset when the cursor is over it.
OnEnterCollider / OnExitCollider - An event can be triggered when a play first touches the collider or when the player leaves the collider.
OnPlayerLookStart / OnPlayerLookEnd - An event can be triggered when the player first looks at the collider or when they stop looking at the collider.
The animation can be triggered using different operations such as setting a parameter, adding / subtracting / multiplying / dividing a parameter, or inverting the parameter. Inverting would be making a 1 turn to a -1, or more importantly turn a true to false or vice versa.
With a bit of creativity these operations allow for a lot of interesting approaches to interactive experiences.
In the Reactor Component example above : if the player enters the Box collider, set the 'doorOut' parameter on the DoorPivot Animator component to true. The Animator would then play the door out animation.
A more complex approach would be if the player interacts with a door, invert the 'doorOpen' parameter on the door Animator component. Each time the player interacts with the door the animation would either open, or close, depending on what state it is currently in.
The parameter itself can be different types as well. A true/false parameter (boolean), whole number (integer/int), a decimal number (float), or a trigger (as in a simple 'Do this!' state).
These parameters align with the parameters that are set in the Animator.
The boolean, int, and float parameters are pretty self explanatory. The Trigger, on the other hand, is a parameter that allows you to set a parameter, but then it stays in its default state to be triggered again easily. Other parameters would need to be changed back before using it again.
The other element that you have access to is the Local toggle on each event. This means that the event will only happen to the player that triggers it, rather than all users in the space.
Now that we have looked into the basics of a reactor system, we can start putting them together.
Events | Operation types | Parameter types |
---|---|---|
OnInteract
Set
Boolean (true/false)
OnEnterTrigger
Addition
Int (-124, 0, 12, 45,231 etc.)
OnExitTrigger
Deletion
Float (-12.432, 5.0, 732.43 etc)
OnPlayerLookStart
Multiplication
Trigger
OnPlayerLookEnd
Division
Invert