Reactor Overview
Reactor is a beta release of the interaction tools for Mona. It is experimental and will have limited support for now, but if you're willing to get your hands dirty it can make cool stuff!
Last updated
Reactor is a beta release of the interaction tools for Mona. It is experimental and will have limited support for now, but if you're willing to get your hands dirty it can make cool stuff!
Last updated
If you are using the Template V1.0, you can get the Reactor tools here.
Mona reactor is an intermediate level interaction tool for the Mona platform. It uses simple events, such as interacting with, entering or exiting, or looking at or away from a collider to trigger parameters in the Unity Animator. You can create objects such as doors and elevators of course. But with some creativity this can be used for nearly anything!
When the avatar first touches or leaves the collider on the object with the Reactor Script, it can tell the target object (with the Animator applied) to trigger specific animations.
Note that the collider needs to have 'Is Trigger' set to true so that you can move through it.
When the user interacts with a reactor object collider using the 'E' key, you can trigger an animation. This feature allows you to specify what text is shown on the event for complete customization.
Note that the collider needs to have 'Is Trigger' set to false so that the player can see it. This will make the collider a physical collider. Due to how Unity does raycasting this cannot be helped.
At the moment OnInteract reactors can not overlap other types of reactors. So an OnInteract cannot be inside an OnExitCollider for example as the OnExitCollider will override the OnInteract. There are usually ways to get the result you are after however.
You can trigger an animation when you look at and when you stop looking at an object (collider).
Note that the collider needs to have 'Is Trigger' set to false so that the player can see it. This will make the collider a physical collider. Due to how Unity does raycasting this cannot be helped.
Reactor is a tool that triggers parameters in an assets Animator component. These parameters tell the asset which animation to transition to.
Think of the Animator like a node graph for different animations with different ways to trigger them. The below example is a simple example transitioning between an open and closed door, but they can get very complex if needed.
Each transition from one animation to the next can be controlled by testing a parameter for true or false, and/or greater than, equal to, or less than operations on numbers. The condition type depends on if the parameter is a boolean (true/false), int (whole number), float (decimal number) or trigger.
So in this example, when the reactor triggers the 'Open' parameter to be true, the door will open. We’ll go into more details on these later in this tutorial.
There are two main elements to the Reactor system :
The Target Object, or the object to animate (Red Box below)
The Reactor Object, any object that has the Reactor script and a collider (Green Box below)
These can be the same object, or different, but for organization purposes it is recommended to keep them separate like the example here.
So, a quick summary of how reactor works :
Player triggers an Event
Entering a collider
Exiting a collider
Interacting with an object based on a collider
Looking at a collider
Looking away from a collider
Reactor defines what happens on that event
Setting a parameter in an objects Animator
Parameter triggers an animation in the Animator
The target object needs an Animator component attached. Inside that Animator is a parameter that the Reactor script will set. The Animator then needs Animation clips in it to transition to/from depending on what the parameter does. Let's set those up first.
You will need both the Animation window, and the Animator window open (found in the Window/Animation panel).
Select your target object you would like to animate
Open the Animation window (not Animator) and select the 'Create' button.
Save the animation (The Animation Folder in the _AddYourArtHere is a good spot for example). This will also add the Animator to the object and add the Animation into it
Animate your object as you see fit.
If your animation shouldn't loop, make sure to change the Loop Time option on the animation clip itself by clicking on the animation clip / Inspector.
Use the pull down with your current animation name at the top left of the Animation window to add any other Animation Clips with Add Animation Clip… This is the easiest way to add new clips to your object. It is easy to add more later through the same process.
Once you have your animations, and the target object selected still, open the Animator Window. Your clips should be visible in the animator. Arrange them neatly so they are easy to navigate.
Right click on the animation clip you would like to be the default state. Set that to the Default state. It should turn Orange.
Next, we can make a Parameter to modify in the Parameters button to the left of the Animator. Reactor will be looking for this when the trigger event has been set. You have the choice of integer (eg. 1, 14, 34126), floats (eg. 3.21, 645.326), Boolean (true or false) and a trigger.
Use the ‘+’ sign to add a parameter, choose which type you would like.
Name the Parameter and remember this parameter name exactly, as you will need this to trigger correctly in the Reactor script later.
Right mouse click the default state and select Make Transition. Move the arrow to the first animation you would like to blend to with your reactor event, and click on it to connect the two.
Click on the newly made arrow, in the Inspector you can edit many elements to the animation, but the main one we want is the On Exit time, the blend time between the animations, and conditions under the frame to trigger the transition. Have a look through the options available such as greater than, equal to, less than, or if a Boolean is true or false. These are the conditions you can affect using the Reactor tool. Apply a condition that suits your purpose.
Add any other parameters and transitions as you see fit. We recommend keeping it simple for a first pass though.
The Reactor Object can be the one with the Animator on it, or a completely different one.
For ease of use, it's usually better to have it running on it's own empty gameobject, either in the scene where the trigger is placed, or as a child of the object you plan to affect (if you need the trigger to be part of the target object). This will make more sense as your systems get more complex.
Whichever one you choose, it needs to have the Reactor script on it, and a collider. Without the collider, the player avatar will have nothing to interact with, so make sure there is one. You can use any kind of collider to interact with including box, sphere, capsule and mesh colliders.
Having the reactor and collider on its own gameobject (as recommended above) will mean there is less conflict with other colliders so the avatar doesn't run through the objects in question.
As noted above there are a number of events you can use on you assets : OnEnterTrigger, OnExitTrigger, OnInteract, OnLookAt, OnLookAway. Note that OnEnterTrigger and OnExitTrigger needs to have the 'Is Trigger' toggle on the collider set to true so the player can run through it. OnInteract, OnLookAt, and OnLookAway needs to have the 'Is Trigger' set to false, so the player can see it. This collider also acts as a physical collider.
Each event will send information from the Reactor Object to the Target objects Animator. The information you send includes the following :
Name - Just the name of the command, has no real function Operation - This is the type of operation on the parameter. See Below. Object - Drag the Target Object into this slot Parameter - This is the parameter in the Animator you will affect Value type - This is the type of parameter such as bool, integer, or float Value - This is the value that is sent to that parameter type
The Operation covers the following operations :
Set - Sets the parameter to the parameter value. Addition - Adds the parameter value to the Animator parameter Minus - Minuses the parameter value from the Animator parameter Multiplication - Multiply the parameter value by the Animator parameter. Division - Divide the Animator parameter by the Parameter value Invert - Switches any parameter to the opposite. - 1 <> -1 - 5.32 <> -5.32 - true <> false For Invert to work (at the moment) the parameter value must have a value of true or false. The value itself is ignored.
Select your Reactor object (the target object, any other object, or preferably an empty object)
Make sure the location of the Reactor object is not at 0,0,0 unless thats where it needs to be. Doing this will have the Gizmo information come from the centre, and that's not so useful. Moving objects that have already been animated 'after' animating them can also lead to unwanted results.
Drag the Reactor Script onto the object. It can be found under Mona/TemplateScripts/MonaReactor in the Project window.
Add a collider to the object (it’s a good habit to get into as it’s easy to forget)
Adjust the collider to where the avatar would touch it to trigger the event. Note it is the first touch, not completely entering the collider.
Use the ‘+’ under the desired trigger event to add a command under the trigger event you would like to use. You can use both trigger events (OnTriggerEnter and OnTriggerExit)on one object without a problem.
Add the information into the command. Make sure that the Parameter Name matches the Parameter in the Animator exactly.
With your Target object animated, the Reactor object set up with the Reactor Script and the collider, you should be ready to go.
Start small to get used to the Reactor system. A simple door or animation trigger is a good place to start, and then get more and more complex. Complex systems are certainly possible, but adds a level of difficulty for each moving part you have in your system. That said, you can get really complex systems to do amazing things.
Make sure to set your objects location correctly from the start (parent objects should be where they are in the world for example, not left at 0,0,0 unless you have a specific reason). Animation is based on the parent of the object, and if you find you need to change the position of the object after it has been animated, you may find it will give you unexpected results. It can be cleaned up after but it is not fun to do so.
We plan on streamlining the process as much as possible over time, so if it’s too difficult in its current state it will be easier to use in the future. It is certainly possible to create an interesting environment by just using animation.
Remember that Reactor is currently in a Pre-Alpha state and therefore will have limited support. We will be continuing to work on it to make it easier to use and in doing so it will continue to evolve over time. That said, we thought it a good opportunity to get the community involved in some of the very exciting developments here at Mona.
If your collider needs to move with the animation so that when you leave the object it triggers the Exit actions, make sure the Reactor Object is a child of the animated object. If the collider is static and your elevator (as an example) moves away from the collider, your avatar leaves the collider, and the OnTriggerExit actions will trigger. Use the Reactor gizmos to help visualize the collider for each reactor script. This may happen on moving objects like elevators.
One issue might be the parameter is set in the Animator to the wrong value (that triggers the first state of the animation). An example would be the OpenDoor boolean parameter is true in the Animator, but that needs to be set by the trigger first...it will animate on starting the scene.
The parameter name in Reactor is different to the parameter in the Animator. Double check that the Reactor Parameter Name matches the Animator Parameters exactly, including upper and lower case.
You have the correct object with the target animation in the Reactor target object slot
You have the correct operation on the transition arrow (using greater than instead of equals for example)
The action hasn’t happened from a duplicate enter/exit event (you may need to turn off the Reactor collider to make sure it doesn’t get triggered again as an example)
If you are using the Invert action type, make sure that ‘true’ or ‘false’ is in the Parameter Value slot even though it will not be used. If it is empty, or any other value, it will not trigger correctly.
Make sure to turn off Loop Time on the animation clip in question by clicking on the Animation clip, and in Inspector you should see Loop Time.