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

Is the Time.deltaTime needed for moving navmeshagent?

Discussion in 'Scripting' started by AnimalPlants, Oct 22, 2021.

  1. AnimalPlants

    AnimalPlants

    Joined:
    Oct 20, 2017
    Posts:
    4
  2. In this case you don't need to do that because the movement is processed by the navmesh itself and it takes care of it.
    You only need to do that when you're calculating the values and do the movement yourself.

    In this case you only give a location (preferably one time and not every frame).
     
  3. AnimalPlants

    AnimalPlants

    Joined:
    Oct 20, 2017
    Posts:
    4
    Hi Lurking Ninja,

    Thank you for your response.

    On my project use like a click then the character tries to go to that location. so the destination is set once.(but called many times).
    but i'm worried like on other computers with fast framerate. the character goes faster.

    is it fine i put the
    agent.destination = destination; in the update method?

    onclick = destination = click destination

    void Update(){
    agent.destination = destination;
    }

    unity does the movment with frame independently?
     
  4. It's not a good thing. If your destination didn't change, do not add it more than once.
    Yes.
     
  5. AnimalPlants

    AnimalPlants

    Joined:
    Oct 20, 2017
    Posts:
    4
    Hi Lurking Ninja,

    Thank you very much for responding.

    Sorry to ask again, i'm very very noob.

    How do i make the agent move a step going to the destination without the
    agent.destination = destination;

    I read it here that to make it move they put it on the update method
    https://docs.unity3d.com/Manual/nav-MoveToClickPoint.html

    how do i make it do 1 step to go to destination? without just setting it again like the one above(agent.destination = destination; )
    like a function to do it?
     
  6. AnimalPlants

    AnimalPlants

    Joined:
    Oct 20, 2017
    Posts:
    4
    Hi Lurking Ninja,
    Thank you for responding again.
    Sorry i was not able to understand it at first.
    Now i understand a bit.
    This is the thing i was looking for.
    https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent-nextPosition.html