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. Dismiss Notice

Bug First click, vector x,y are always 0

Discussion in 'Input System' started by amiga4K, May 13, 2022.

  1. amiga4K

    amiga4K

    Joined:
    Jan 30, 2018
    Posts:
    68
    Hi, I'm making some test on new input system and I discoverd that when I try to get the first click of mouse or of a touch the Vector position is 0. However next clicks return a non 0 Vector.

    Here it my configurations:
    • Windows 10
    • Unity 2021.3.01f
    • Input System 1.3
    • Game Run in Simulator Window
    The controls asset (PlayerControls.inputactions) is configured as follows:

    Unity_DL5iABV8H8.png

    The code is the following:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class InputManager : MonoBehaviourSingletonPersistent<InputManager>
    6. {
    7.     PlayerControls playerControls;
    8.  
    9.     Vector2 initialPosition;
    10.  
    11.     private void OnEnable()
    12.     {
    13.         playerControls.Enable();
    14.  
    15.     }
    16.  
    17.     private void OnDisable()
    18.     {
    19.         playerControls.Disable();
    20.     }
    21.  
    22.     public override void Awake()
    23.     {
    24.         base.Awake();
    25.         playerControls = new PlayerControls();
    26.     }
    27.  
    28.     // Start is called before the first frame update
    29.     void Start()
    30.     {
    31.         playerControls.Player.Click.performed += _ => SetInitialPosition();
    32.     }
    33.  
    34.     // Update is called once per frame
    35.     void Update()
    36.     {
    37.         Vector2 pos = playerControls.Player.CameraMove.ReadValue<Vector2>();
    38.     }
    39.  
    40.     void SetInitialPosition()
    41.     {
    42.         initialPosition = playerControls.Player.CameraMove.ReadValue<Vector2>();
    43.         print(initialPosition);
    44.     }
    45. }
    Thanks.
     
    Last edited: May 17, 2022
  2. lhicks

    lhicks

    Joined:
    Oct 17, 2021
    Posts:
    18
    I'm having this issue too. Input System 1.3, Unity 2021.2.16f1

    My internet search seems to indicate this was a bug in a previous version of Input System in 1.0 that was supposedly fixed about a year ago, but perhaps there was a regression?
     
  3. amiga4K

    amiga4K

    Joined:
    Jan 30, 2018
    Posts:
    68
    Unfortunately, the bug is still present. I do not understand how there is no response from the Unity team. We are talking about a critical component for game development. And we are at version 1.3...
     
  4. SceneForgeStudio

    SceneForgeStudio

    Joined:
    Feb 28, 2017
    Posts:
    466
    @amiga4K @lhicks Hey, I'm experiencing a bug that I think is similar, do you mind clarifying?

    For some reason now, I am unable to drag sliders (or get mouse input in update) and have to click every time to update the position. Is what you are referring to?
    This happens in builds too.

    I just updated my project to 2021.3 from 2021.1.28 and now I'm seeing this very frustrating bug.

    Thanks!
     
    Last edited: May 17, 2022