Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question When releasing two buttons in the new Input System it detects the differences

Discussion in 'Input System' started by LGDCompany, May 4, 2022.

  1. LGDCompany

    LGDCompany

    Joined:
    Jun 14, 2018
    Posts:
    4
    I've been creating a game that uses the input system for moving the player

    Code (CSharp):
    1. _playerInput.actions["Move"].performed += x =>
    2.         {
    3.             // We're moving
    4.             _walking = true;
    5.             // Set the movement input to the value passed by the player
    6.             _movementInput = x.ReadValue<Vector2>();
    7.             // The angle that we need the player to rotate towards so the player look where he's moving and we change it to be in degree
    8.             _targetAngle = Mathf.Atan2(_movementInput.x, _movementInput.y) * Mathf.Rad2Deg + cam.eulerAngles.y;
    9.         };
    Here is my code but when I use the Arrows to move like the right and up Arrow and I want to release them it detects the smallest difference between the release of the two buttons which is near impossible to avoid (difference between release)
    before releasing "_movementInput" contains (0.71, 0.71) but after release it becomes (0, 1) or (1, 0).
    I want it to stay (0.71, 0.71) as it was before releasing the two buttons