Adventure Creator Wikia
Advertisement

By default, running in Point and Click mode is a case of double-clicking in the scene. This script allows the Player to also run based on a dedicated "Run" input key.

To use it:

  1. Create a new C# script named HoldRun, and copy/paste the code below
  2. Attach the new Hold Run component to your Player character
  3. Define an input named "Run"

HoldRun.cs:

using UnityEngine;
using AC;

public class HoldRun : MonoBehaviour
{

	private void OnEnable () { EventManager.OnCharacterSetPath += OnCharacterSetPath; }
	private void OnDisable () { EventManager.OnCharacterSetPath -= OnCharacterSetPath; }

	void Update ()
	{
		if (!KickStarter.stateHandler.IsInGameplay () || !KickStarter.player.IsMovingAlongPath ()) return;

		if (KickStarter.playerInput.InputGetButtonDown ("Run"))
		{
			KickStarter.player.isRunning = true;
		}
		if (KickStarter.playerInput.InputGetButtonUp ("Run"))
		{
			KickStarter.player.isRunning = false;
		}
	}

	void OnCharacterSetPath (AC.Char character, Paths path)
	{
		if (character == KickStarter.player && KickStarter.stateHandler.IsInGameplay () && KickStarter.playerInput.InputGetButton ("Run"))
		{
			KickStarter.player.isRunning = true;
		}
	}

}
Advertisement