Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Input Axis lags and locks up [5.5.0p4]

Discussion in 'Editor & General Support' started by 4t0m1cw07f, Jan 25, 2017.

  1. 4t0m1cw07f

    4t0m1cw07f

    Joined:
    Nov 2, 2015
    Posts:
    3
    Hi,

    I've got this very basic control script that takes the axis input and feeds it to the animator for root motion but the input often lags out and gets stuck until a few seconds later. I've checked the profiler and there's nothing suspicious that I can see.

    Code (CSharp):
    1. void Update () {
    2.  
    3.         //Attack
    4.         AttackCtrl ("Attack");
    5.  
    6.         //Run
    7.         RunCtrl ("Run");
    8.  
    9.         //Move
    10.         MovementCtrl (_player.GetAxis ("Horizontal"), _player.GetAxis ("Vertical"));
    11.  
    12.     }
    13.  
    14.     void AttackCtrl (string button){
    15.         if (_player.GetButtonDown(button) && _animator.GetBool("AttackLock") == false){
    16.             // Debug.Log (button);
    17.             _animator.SetBool("Attacking", true);
    18.         }
    19.     }
    20.  
    21.     void RunCtrl (string button){
    22.         if (_player.GetButtonDown(button)){
    23.             // Debug.Log (button);
    24.             _animator.SetBool("Running", true);
    25.         } else if (_animator.GetBool("Running") && _player.GetButtonUp(button)){
    26.             _animator.SetBool("Running", false);
    27.         }
    28.     }
    29.  
    30.     void MovementCtrl (float H, float V){
    31.         if (H != 0 || V != 0) {
    32.  
    33.             //Move
    34.             _animator.SetBool("Moving", true);
    35.            
    36.             //Face Analog Direction
    37.             float myAngle = Mathf.Atan2 (H,V) * Mathf.Rad2Deg;
    38.             transform.eulerAngles = new Vector3 (0, myAngle, 0);
    39.  
    40.         } else {
    41.             _animator.SetBool("Moving", false);
    42.         }
    43.     }
    Here I was merely running in circles and you can see twice how the input locks up. There are also no major anomalies in the profiler.


    I've also included a screenshot of the profiler exactly at a point during a lock up. There's a 3.5ms time on WaitForTargetFPS. Not sure if that's a bad thing.