Search…
Reactor (Experimental)
Reactor is a pre-alpha 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!
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 to trigger parameters in the Unity Animator, which is very powerful in its own right. You can create objects such as doors and elevators of course. But with some creativity this can be used for nearly anything!
At the moment events are limited to OnTriggerEnter and OnTriggerExit. So 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.
Think of the Animator like a node graph for different animations with different ways to trigger them. Each transition from one animation to the next can be controlled by simple game logic such as testing a parameter for true or false, and/or greater than, equal to, or less than operations on numbers. 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
  • The Reactor Object, any object that has the Reactor script and a collider
These can be the same object, or completely different. So you can have a switch from across the room open a door, or you can have the door itself trigger its own animations.

The Target Object

The target object needs a couple of things to work for Reactor to trigger. It will need an Animator component with some parameters to trigger with the Reactor script. And that Animator needs Animation clips in it to transition to/from. Let's set those up first.

Creating the Target Object

  • You will need both the Animation window, and the Animator window open.
  • Select your target object you would like to animate
  • Add an Animator component to it in the inspector
  • Open the Animation window (not Animator) and select Create.
  • Save the animation (The Animation Folder in the _AddYourArtHere is a good spot for example). This will add the Animator to the object and add the Animation into it
  • Animate your object as you see fit. As Animator can transition between animations over time (that you can set in Animator), in simple use cases you can have the first frame of your animation as the starting state, and the end location as a single frame on the target state. And easily transition between the two. This will make more sense when we get into the Animator.
  • 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), or Boolean (true or false). Reactor does not use the trigger parameter.
  • 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

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 it's 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.
The two trigger events available at the moment are OnTriggerEnter, and OnTriggerExit. So when the Avatar touches the collider, or leaves the collider on the Reactor Object, the commands under each trigger event will be set. You can set a number of commands, and even target different objects with the one trigger event. More events will be added in the future however.
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.

Creating the Reactor Object

  • 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.

Hints and Tips

  • 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.

Troubleshooting

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.

My OnTriggerExit/OnTriggerEnter action is triggering when it shouldn’t

  • 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.

My Animation isn’t triggering

  • 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)

My Invert action type isn’t triggering

  • 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.

My animation keeps looping when it shouldn't

  • 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.
Last modified 7d ago