FANDOM


This script demonstrates how AC can make use the free Simple Touch Controller asset. It allows for joysticks to override the Horizontal and Vertical axes, as well as free-aiming.

Attach the script to any active object in the hierarchy, and configure the fields. Note that the "CustomGetFreeAim" method is only useful in first-person, and can be removed if you're not using it.

ACInputSTC.cs:

using UnityEngine;

public class ACInputSTC: MonoBehaviour
{

public SimpleTouchController moveController;
public SimpleTouchController aimController;


void Start ()
{
AC.KickStarter.playerInput.InputGetAxisDelegate = CustomGetAxis;
AC.KickStarter.playerInput.InputGetFreeAimDelegate = CustomGetFreeAim;
}


private float CustomGetAxis (string axisName)
{
if (axisName == "Horizontal")
{
return moveController.GetTouchPosition.x;
}
if (axisName == "Vertical")
{
return moveController.GetTouchPosition.y;
}

try
{
return Input.GetAxis (axisName);
}
catch
{
return 0f;
}
}


private Vector2 CustomGetFreeAim (bool cursorIsLocked)
{
return aimController.GetTouchPosition;
}

}
Community content is available under CC-BY-SA unless otherwise noted.