Search Unity

NavAgent stuttering when player gets close.

Discussion in 'Navigation' started by EDevJogos, Aug 5, 2016.

  1. EDevJogos

    EDevJogos

    Joined:
    Jul 24, 2014
    Posts:
    75
    I'm moving my player like this:

    Code (CSharp):
    1. Update()
    2.     {
    3.         if (_isAccelerating && _speed < FarmStableManager.SELECTED_CAMEL_DATA.topSpeed)
    4.         {
    5.             _speed += 6f * Time.deltaTime;
    6.         }
    7.         else
    8.         {
    9.             _speed -= 10f * Time.deltaTime;
    10.             _speed = _speed <= 0f ? 0f : _speed;
    11.         }
    12.        
    13.         _rigidbody.velocity = transform.forward * _speed;
    14.     }
    15.  

    And i have a couple of AIs moving with NavMeshAgent, the problem is everytime my player gets close to any of the AIs they start to stutter, i've already checked the proffiler everything seams fine, the FPS rate is ok, i don't know why this is happening. Also, if i use transform.Translate this dosen't happen.

    The weird part is that my player runs just fine, only the AI objects that start stuttering and only when the player is close ( not colliding, just nearby ) and moving.
     
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,335
    Your nav code butts head with the agent's auto-breaking, turn that off.