private void InputManager_OnChanges() { inputs?.Disable(); inputs = InputManager.GetInputActions(playerNumber); inputs.Player.Charge.started += Charge_started; inputs.Player.Charge.canceled += Charge_canceled; inputs?.Enable(); }
/// <summary> /// Get action map with correct device for player number /// </summary> /// <param name="playerNumber"></param> /// <returns></returns> public static InputSystemControls GetInputActions(int playerNumber) { if (!playerIdToDevices.ContainsKey(playerNumber)) { SetUpPlayerNumbers(numberOfPlayers); RevaluateAllDevices(); if (playerIdToDevices.ContainsKey(playerNumber)) { return(null); } } InputSystemControls actions = new InputSystemControls(); actions.devices = playerIdToDevices[playerNumber].ToArray(); return(actions); }
private Vector2 lookDirection; // position in space to look at //private bool grounded = false; // is player touching the ground? /** * Grab an instance of our rigidbody and controls. Also make sure that we disable * our gravity and freeze rotation. Unity gravity is not programmed correctly, and * should bethe square power of gravity, not */ public void Awake() { Controls = new InputSystemControls(); // load out control system RB = GetComponent <Rigidbody>(); // reference rigidbody physics RB.freezeRotation = true; // disables tumbling around RB.useGravity = false; // use our own custom gravity // error checking for sanity if (LookTarget == null) { LookTarget = transform.Find("Look Target"); // look for default if not defined if (LookTarget == null) // check if the scene has a target { throw new System.NullReferenceException( "Please set `Look Target` property of the `PlayerController`"); } } }