Adventure Creator Wikia
Advertisement

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:

  1. To your Motion Controller character, add either AC's Player or NPC component, depending on their type
  2. In the Player or NPC Inspector, set their Animation engine to Custom, and Motion control to Manual
  3. Create a C# script named CustomControllerLink and paste in the code below
  4. Attach the Custom Controller Link component to your character
  5. Make sure that your character has the Nav Mesh Input Source and Motion Controller components attached
  6. 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;
		}
	}
}
Advertisement