private void Update() { movement.Move(player.GetAxis2D("Move Horizontal", "Move Vertical")); //Debug.Log(player.GetAxis2D("Move Horizontal", "Move Vertical")); if (player.GetButton("Fire")) { FireButtonPressed(); } if (player.GetButton("Fire2")) { Fire2ButtonPressed(); } if (player.GetButton("Dash")) { DashButtonPressed(); } if (mouseInput) { Vector3 v_diff = (MouseTargetLocation.position - transform.position); float Rad = Mathf.Atan2(v_diff.y, v_diff.x); float angle = Rad * Mathf.Rad2Deg; rotationEvent.Invoke(angle); } else { rotationEvent.Invoke(Quaternion.LookRotation(player.GetAxis2D("Rotate Horizontal", "Rotate Vertical")).eulerAngles.z); // Debug.Log(Quaternion.LookRotation(player.GetAxis2D("Rotate Horizontal", "Rotate Vertical")).eulerAngles.z); } }
private Vector3 GetMoveInput() { if (m_moveInterpreter == null) { return(Vector3.zero); } Vector2 rawMoveInput = m_input.GetAxis2D(Action.MoveHorizontal, Action.MoveVertical); Vector2 clampedMoveInput = Vector2.ClampMagnitude(rawMoveInput, 1); return(m_moveInterpreter.Interpret(clampedMoveInput, m_gravityNormal)); }
public override void DoUpdate() { for (int i = 0; i < actions.Length; i++) { ActionPair pair = actions[i]; switch (pair.def.kind) { case InputAction.Kind.Button: { // Fix something here! Is called for 5/6 Frames bool held = player.GetButton(pair.def.rewiredAction1); bool oldHeld = pair.action.buttonHeld; var change = held == oldHeld ? InputAction.ValueChange.None : held ? InputAction.ValueChange.NotZero : InputAction.ValueChange.Zero ; pair.action = new InputAction(held, change); break; } case InputAction.Kind.Axis: { float value = player.GetAxis(pair.def.rewiredAction1); float oldValue = pair.action.axis; var change = value == oldValue ? InputAction.ValueChange.None : Math.Abs(value) > 0.0f ? InputAction.ValueChange.NotZero : InputAction.ValueChange.Zero ; pair.action = new InputAction(value, change); break; } case InputAction.Kind.Axis2D: { Vector2 value = player.GetAxis2D(pair.def.rewiredAction1, pair.def.rewiredAction2); Vector2 oldValue = pair.action.axis2D; var change = value.sqrMagnitude == oldValue.sqrMagnitude ? InputAction.ValueChange.None : value.sqrMagnitude > 0.0f ? InputAction.ValueChange.NotZero : InputAction.ValueChange.Zero ; pair.action = new InputAction(value, change); break; } } } }
private void Awake() { player = ReInput.players.GetPlayer(0); Debug.Log(player.GetAxis2D("Move Horizontal", "Move Vertical")); }