This script integrates AC with ooti's Third Person Motion Controller asset.
The construction of this script is covered in this tutorial on the AC website.
To use it:
- To your Motion Controller character, add either AC's Player or NPC component, depending on their type
- In the Player or NPC Inspector, set their Animation engine to Custom, and Motion control to Manual
- Create a C# script named CustomControllerLink and paste in the code below
- Attach the Custom Controller Link component to your character
- Make sure that your character has the Nav Mesh Input Source and Motion Controller components attached
- Supply a Unity Input Source in the Inspector for the character to use when under player control during gameplay.
CustomControllerLink.cs:
using UnityEngine;
using System.Collections;
using com.ootii.Input;
using com.ootii.Actors.AnimationControllers;
using AC;
public class CustomControllerLink : MonoBehaviour
{
private NavMeshInputSource navMeshInputSource;
public UnityInputSource unityInputSource;
private MotionController motionController;
private Char acCharacter;
private void Start ()
{
navMeshInputSource = GetComponent <NavMeshInputSource>();
motionController = GetComponent <MotionController>();
acCharacter = GetComponent <Char>();
}
private void Update ()
{
if (!KickStarter.stateHandler.IsInGameplay () ||
(!acCharacter.IsPlayer || KickStarter.settingsManager.movementMethod == MovementMethod.PointAndClick)
|| acCharacter.IsMovingAlongPath ())
{
navMeshInputSource.TargetPosition = acCharacter.GetTargetPosition (true);
motionController.InputSource = navMeshInputSource;
}
else
{
motionController.InputSource = unityInputSource;
}
}
}