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

NavMesh Agent rotation speed ?

Discussion in 'Scripting' started by Quast, Jun 7, 2017.

  1. Quast

    Quast

    Joined:
    Jul 5, 2015
    Posts:
    560
    Hi guys;
    My problem is with rotation of the Navmesh agent object. I want to make a controller for the rotation speed. here is my simple script.

    Code (CSharp):
    1.     public Transform originPosition;
    2.     NavMeshAgent _agent;
    3. public float rotation_speed; // how to use it with _agent ?
    4.     void Start () {
    5.         _agent = GetComponent<NavMeshAgent>();
    6.     }
    7.    
    8.     void Update () {
    9.         gameObject.transform.position = originPosition.transform.position - originPosition.transform.forward ;
    10.  
    11.         _agent.speed = 5.5f;
    12.         _agent.angularSpeed = 6;
    13.         _agent.acceleration = 10;
    14.    
    15.     }
    If I increased the rotation_speed value, the agent object rotation become more faster ?
     
  2. KKmainK

    KKmainK

    Joined:
    Sep 7, 2016
    Posts:
    11

    I know it's late, but not better unanswered

    Not sure how you plan to design the controller but by increasing the angular speed of the the nav mesh agent the agent rotation increases.
     
    StreaKV and Quast like this.
  3. gneissler

    gneissler

    Joined:
    Jun 2, 2017
    Posts:
    3
    if you want to change the rotation speed "angular speed" you also need to increase the acceleration because move and rotation speed both depend on it. you can look at "acceleration" as some sort of smoothing for all sorts of movement the NavMeshAgent does. the higher the number the quicker each action is to get into full gear.

    make shure to set the acceleration to something around the agents speed and set the angular speed to 360 or something
     
    Last edited: Jul 29, 2020
    StreaKV, zelderus and Influ3nce like this.