Latest Version: 0
The animator events tool is a key aspect of setting up user reactivity in a scene. It permits scene designers to create state machines, which can be applied to any purpose within a scene. The typical application is to create user-controlled or user-influenced character behavior, but it could be used for many purposes.
This is used to control multiple animated characters in the 3D Animation to multiplatform game tutorial.
How to use
- Apply this script to any game object with an animator component.
- Configure it to listen to events from the animator or send new information to an animator.
Section Information
Basic Settings
The Basic Settings section contains 2 parts and some additional instructions.
- The Base State name
- The Option Name
- Instructions on how to use these as well as triggers
The Base State Name is a string that should correspond to an integer parameter inside the animator. The idea with this is that the creator makes a state machine in the animator using an integer parameter to control it. The name put here should exactly match the integer parameter in the animator. When an event creator of any sort calls the function “SetBaseState” on this script, it will change the parameter with this name with the number sent in the event.
The Option Name is similar to the base state function, but instead of being tied to an integer parameter, it is tied with a bool parameter. The animator should have a bool parameter with the exact same name as typed here. When an event creator of any sort calls the function “SetBool” on this script, it will change the parameter with this name with the true or false value in the event.
There are additional instructions on how to send Trigger type messages to the animator. SetTrigger called from any event creator will set the trigger with the same name as the string sent in the event. The combined capabilities of these 3 techniques permits most kinds of automated behaviors.
Animation Events
The Animation Events section contains 1 part
- The Animation Events
The animation events array allows you to make arbitrary unity events happen in response to an animator event embedded in an animation. Animator events can be created in any animation, and they should call the function “React To Animation Event.” When that animation is played, the number on the animation event will call the unity event in this list. The number is a reference to the index in this list, so sending a “0” would call the first item, “1” would call the second, and so on.
Create a new animation event inside an animation by right-clicking below the timeline in the “Animation” tab where you want the event to be. This will bring up a context menu that allows you to “Add Animaton Event.” Do that, and in the inspector you will be given the option of setting this to call React To Animation Event and provide a number to use.
State Events
The State Events section contains 1 part
- The State Events
This part listens for events called by the Animator State Notifier tool, which lives on individual states in an animator. When the Animator State Notifier enters or exits a state, it can call the Unity event associated with the index number in this array. Having that tool send a “0” calls the first event on this list, having it send a “1” calls the second, and so on.
State events are called from within a “Try” block so it doesn’t crash the game when it fails, though it does operate more slowly as a consequence. Don’t use this on every frame.