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

agent.isStopped does not stop immediately

Discussion in 'Scripting' started by sickb0y247, May 1, 2020.

  1. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    51
    Hi all,

    I notice a bit of a drag when I use isStopped on the agent. I noticed this used to be handled by the Stop() method and putting true in the parameter would stop the agent immediately but this is now considered outdated and isStopped doesn't have this sort of option for it.

    Is there another way I should be doing this to stop the agent immediately? I'd prefer not to disable/enable the agent if possible as I'd like for it to keep it's destination data intact.
     
  2. sbalanoff

    sbalanoff

    Joined:
    Nov 14, 2019
    Posts:
    36
    Hi! This would be because it still has it's destination data, like you said. What I would do is create a Vector3 called data, and when you want to stop you set the data variable to the destination position. That way when you start again you set the destination to that data.
     
    sickb0y247 likes this.
  3. sickb0y247

    sickb0y247

    Joined:
    May 29, 2014
    Posts:
    51
    Thanks for the help! Disable/enable and keeping the destination in a variable does work. I was hoping for a simple pause feature that stops the agent immediately but at least this works. Thank you!