Forum rules - please read before posting.

CursorHorizontal and Vertical on new input manager

Hello Chris,

Is there a way to simulate CursorHorizontal and Vertical freeaiming on script?

I want to support multiple controllers/gamepads but it seems their axis' are different to define them on old Input Manager

I can define as much as controllers on the new one and call a function on the axis change. Is there a function I can call providing the vector2 movement variable?

or is there any other way to support different controllers?

Thanks

Comments

  • edited June 2020

    Is there a function I can call providing the vector2 movement variable?

    Not a Vector2, as the inputs are read separately, but you can provide override hooks for axis reading.

    See the Manual's "Remapping inputs" chapter for a rundown, but an example script that lets you switch between different axes for CursorHorizontal would be as follows:

    using UnityEngine;
    using AC;
    
    public class CustomCursorInput : MonoBehaviour
    {
    
        public int mode;
    
        void Start ()
        {
            KickStarter.playerInput.InputGetAxisDelegate = CustomGetAxis;
        }
    
        float CustomGetAxis (string axisName)
        {
            if (axisName == "CursorHorizontal")
            {
                switch (mode)
                {
                    case 0:
                        return Input.GetAxis ("Gamepad1_Horizontal");
    
                    case 1:
                        return Input.GetAxis ("Gamepad2_Horizontal");
    
                    case 2:
                        return Input.GetAxis ("Gamepad3_Horizontal");
                }
                return 0f;
            }
            try
            {
                return Input.GetAxis (axisName);
            }
            catch {}
            return 0f;
        }
    
    }
    
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.