Adventure Creator Wikia
Advertisement

This script can be used to switch the game's "Movement method" between "Direct" and "Point And Click", based on the last input.

To use it:

  1. Create a new C# file named DynamicMovement.cs and paste in the code below
  2. Create a new GameObject in the scene and attach the new Dynamic Movement component
  3. When a keyboard key is pressed, the game will switch to Direct movement. When the mouse is pressed, it will switch to Point And Click
  4. (Optional) The script's SetMovementMethod function can be modified to run any additional desired code at the time such a switch occurs
using UnityEngine;
using AC;

public class DynamicMovement : MonoBehaviour
{

    [SerializeField] private MovementMethod defaultMovementMethod;

    private void Start ()
    {
        SetMovementMethod (defaultMovementMethod, true);
    }

    private void Update ()
    {
        if (Input.anyKeyDown)
        {
            if (Input.GetMouseButtonDown (0) || Input.GetMouseButtonDown (1) || Input.GetMouseButtonDown (2))
            {
                SetMovementMethod (MovementMethod.PointAndClick);
            }
            else
            {
                SetMovementMethod (MovementMethod.Direct);
            }
        }
    }

    private void SetMovementMethod (MovementMethod movementMethod, bool force = false)
    {
        if (KickStarter.settingsManager.movementMethod != movementMethod || force)
        {
            KickStarter.settingsManager.movementMethod = movementMethod;

            switch (movementMethod)
            {
                case MovementMethod.Direct:
                    KickStarter.player.EndPath ();
                    break;

                default:
                    break;
            }
        }
    }

}
Advertisement