SILVIA and Mecanim Example

The Avatar would have a Mecanim state machine with Idle, several gestures for speaking with body emphasis and a procedural IK setup for hands and feet control and a set of waypoints or NavMesh to navigate from and to any individual exhibit. When arriving at that exhibit SILVIA would have a variable set so that the knowledge of that exhibit is the focus of responses and behaviors. An exhibit viewer could ask questions and receive answers from the SILVIA driven Avatar.

More generally speaking SILVIA responses would drive or trigger the chosen Mecanim animation states or conversely the Mecanim animation state would drive the choice of SILVIA response. As an example you are setting up a generic “Yes-No-I don’t know” response behavior from SILVIA to drive a Mecanim setup with Idle, HeadShakeNo, HeadNodYes and Shrug animation states, each triggered by a bool.

A simple setup for this would involve the creation of two matched index Arrays with one being an Array of the string names of the states which would also correlate with the strings SILVIA uses for the setting of the bool within the brain file and the other being the Array of bools for keeping track of the current state. In a MonoBehaviour named AvatarAnimationController the following public references would be set up.

public Animator animator;
public string[] stateNames = new string[]{“Idle”, “HeadShakeNo”, “HeadNodYes”, “Shrug”};

SILVIA has run the input thru the AI intent engine and the generated response for speaking would be an affirmative “Yes” or “That’s correct”, an informal “Uh-huh” or similar as the case may dictate. In conjunction with the response SILVIA will fire a call to the AvatarAnimationController to set the Animator state with the bool name “HeadNodYes” to true.

To access the methods of this component, declare a public reference in a Behavior labeled group “default” and name “boot”, in the Pre- or Post-Exuder Section of the Behavior Scripts.

public AvatarAnimationController animationController;

The SILVIA code for firing the method to SetAvatarAnimationState in later Behaviors associated with Avatar command and control would follow this template which is the standard Invoke Wrapper for Confirmed Commands. You would call the component method you defined in the SILVIA Boot Behaviour script which sets that state and bool and as well sets an internal to the Core variable for tracking intention state of the SILVIA brain. You would always set the bool to return true to indicate you are sure you want to execute a command.

public bool Invoke() { core.SetVariable(_stateName);
animationController.SetAvatarAnimationState(_stateName); return true;

Then in animationController this method receives the call and sets the state to true and others to false to avoid having more than one bool true at a time which can cause confusion and false transitions to firing states that were not intended to be fired.

public void SetAvatarAnimationState (string _stateName) { for (int i = 0; i < stateNames.Length; i++) {
if (stateName[i] == _stateName) { animator.SetBool(_stateName, true); stateBool[i] = true;
} else {
animator.SetBool(stateName[i], true); stateBool[i] = false;