All Classes Namespaces Functions Variables Enumerations Properties Pages
Interaction System

The Interaction System is designed for the easy setup of full body IK interactions with the dynamic game environment. It requires a character with FullBodyBipedIK and consists of 3 main components: InteractionSystem, InteractionObject and InteractionTarget.


Getting started:





Getting started with scripting:


using RootMotion.FinalIK;
public InteractionSystem interactionSystem; // Reference to the InteractionSystem component on the character
public InteractionObject button; // The object to interact with
public bool interrupt; // If true, interactions can be called before the current interaction has finished
void OnGUI() {
// Starting an interaction
if (GUILayout.Button("Press Button")) {
interactionSystem.StartInteraction(FullBodyBipedEffector.RightHand, button, interrupt);
}
}

See the API reference of the Interaction System for all the interaction functions. See the Interaction demo scene and the InteractionDemo.cs for more examples.

Components of the Interaction System

InteractionSystem

This component should be added to the same game object that has the FBBIK component. It is the main driver and the main interface for controlling the interactions of its character.

Component variables:

InteractionSystemComponent.png


InteractionObject

This component should be added to the game objects that we wish to interact with. It contains most of the information about the nature of the interactions. It does not specify which body part(s) will be used, but rather the look and feel and the animation of the interaction. That way the characteristics of an interaction are defined by the object and can be shared between multiple effectors. So for instance a button will be pressed in the same manner, regardless of which effector is used for it.

Animating Interaction Objects:
The Interaction System introduces the concept of animating objects rather than animating characters. So instead of animating a character opening a door or pressing a button, we can just animate the door opening or the button being pressed and have the Interaction System move the character to follow that animation. This approach gives us great freedom over the dynamics of the interactions, even allowing for multiple simultaneous animated interactions. You can animate an Interaction Object with the dope sheet and then call that animation by using the OnStartAnimation, OnTriggerAnimation, OnReleaseAnimation and OnEndAnimation animator events that you can find on the InteractionObject component.

Component variables:

InteractionObjectComponent.png


InteractionTarget

If the Interaction Object has no Interaction Targets, the position and rotation of the Interaction Object itself will be used for all the effectors as the target. However if you needed to pose a hand very precisely, you will need to create an Interaction Target. Normally you would first pose a duplicate of the character's hand, parent it to the Interaction Object and add the InteractionTarget component. The Interaction Objects will automatically find all the Interaction Targets in their hierarchies and use them for the corresponding effectors.

InteractionTarget.png

Working with Interaction Targets:

Component variables:

InteractionTargetComponent.png


InteractionTrigger

With most Interaction Objects, there is a certain angular and positional range in which they are naturally accessible and reachable to the character. For example, a button can only be pressed with a left hand if the character is within a reasonable range and more or less facing towards it. The Interaction Trigger was specifically designed for the purpose of defining those ranges for each effector and object.

InteractionTriggerDoor.png

The image above shows an InteractionTrigger defining the ranges of interaction with a door handle for the left hand and for the right hand."
The green sphere is the trigger Collider on the game object that will register this InteractionTrigger with the InteractionSystem of the character.
The circle defines the range of position in which the character is able to interact with the door.
The purple range defines the angular range of character forward in which it is able to open the door with the right hand, the pink range is the same for the left hand.

Getting started

The InteractionSystem will automatically maintain a list of triggers that the character's collider is in contact with. That list can be accessed by InteractionSystem.triggersInRange; That list contains only the triggers that have a suitable effector range for the current position and rotation of the character.

You can find the closest trigger for the character by:

int closestTriggerIndex = interactionSystem.GetClosestTriggerIndex();

if GetClosestTriggerIndex returns -1, there are no valid triggers currently in range. If not, you can trigger the interaction by

interactionSystem.TriggerInteraction(closestTriggerIndex, false);

See the Interaction Trigger demo scene and the UserControlInteractions.cs script for a full example on how to make the Interaction Triggers work.

Component variables

InteractionTriggerComponent.png
InteractionTriggerRightHand.png
Valid position of the character without 'Orbit'
InteractionTriggerRightHandOrbit.png
Valid positions of the character with 'Orbit'