Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by castor · Oct 07, 2016 at 12:48 AM · velocitynavmeshagentstopagentsliding

How to stop NavMeshAgent immediately?

So I have a situation where I need the Agent to stop at the exact spot that he is in the moment I ask him to do so. I'm current using the NavMeshAgent.Stop() but he still slides about 0.1cm before actually stopping.

I noticed the old documentation had a NavMeshAgent.Stop(true):

stopUpdates If true, the GameObject is stopped immediately and not affected by the avoidance system.

But that is now deprecated. I also tried to set his velocity = Vector3.zero before stopping him but still the agent slides.

Here are my NavMeshAgent settings in case it helps: alt text

Any help very appreciated!

agentsettings.jpg (18.9 kB)
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image castor · Nov 14, 2016 at 07:08 PM 0
Share

Anyone? Some help would be really useful.

avatar image brunocoimbra · Nov 14, 2016 at 07:43 PM 0
Share

Setting the velocity to zero and then calling stop used to work for me (no way to test right now), but if that doesn't works: are you calling the Stop method inside the FixedUpdate? If so, try moving it to Update ins$$anonymous$$d.

avatar image Naphier · Nov 14, 2016 at 08:43 PM 0
Share

$$anonymous$$aybe try updatePosition = false?

12 Replies

· Add your reply
  • Sort: 
avatar image
13

Answer by TacticalBlank · Nov 26, 2017 at 01:58 AM

I know this is old, but since all the current answers are downvoted and I don't see the correct solution here, I'll post it. To stop:

 gameObject.GetComponent<NavMeshAgent>().isStopped = true;

And to start it again:

 gameObject.GetComponent<NavMeshAgent>().isStopped = false;
Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ziplock9000 · Nov 01, 2018 at 05:48 PM -1
Share

Things like this are hacks.. Not your fault, but Unity. isStopped should be able to be created in a false mode. Ins$$anonymous$$d of it being instances in a true mode and then rushing to set it to false before anything happens.

avatar image TacticalBlank Ziplock9000 · Nov 10, 2018 at 06:59 PM 0
Share

Not really sure what you're going on about, you may be right that it's a hack, but nonetheless, it solves the problem.

avatar image Ziplock9000 TacticalBlank · Nov 11, 2018 at 11:29 AM -1
Share

You're not sure what I'm going on about and then immediately confirm you know what I'm talking about. Hmm.. Seems legit.

Show more comments
avatar image AlexDev_Official · Apr 06 at 02:44 PM 0
Share

helped me , thank you

avatar image
9

Answer by KellyeAnnora · Mar 31, 2020 at 05:47 PM

Just had this issue and solved it by setting the NavMeshAgent's destination to the object's current position. So basically:

gameObject.GetComponent().SetDestination(gameObject.transform.position);

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image joekuka · Mar 05, 2021 at 09:17 PM 0
Share

Mahalo I just ran into the same issue and this fixed it right up!

avatar image deadlykam · Jul 29, 2021 at 04:01 PM 0
Share

@KellyeAnnora That's a very clever idea. I did that and it worked. Thanks for the tip. :)

avatar image
4

Answer by HHess · Apr 10, 2019 at 11:11 AM

I use gameObject.GetComponent<NavMeshAgent>().velocity = Vector3.zero

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Shiraz_V_Kamar · Jan 28, 2021 at 11:48 AM 0
Share

I dont think that would stop the player from from moving, it would only set the nav$$anonymous$$eshAgent velocity to zero for few frames and it would start to move towards the setdestination point.

avatar image sarynth Shiraz_V_Kamar · Jan 28, 2021 at 04:13 PM 0
Share

Depending on your game and your use case, setting velocity to zero every frame might work for your needs. That's what I'm doing in my game and it works great for me :)

avatar image
2

Answer by AntonioV360 · Apr 07, 2017 at 11:30 PM

 gameObject.GetComponent<NavMeshAgent>().enabled = false;
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by shadowpuppet · Apr 09, 2017 at 12:05 AM

I agree with Antonio. I just .enable = false the navmesh. Make sure autobraking is on , that stops the agent faster ( than NOT on) but disabling the navmesh is how I do it

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
  • 1
  • 2
  • 3
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Is it possible to store NavMeshAgents paths and assign them to other NavMeshAgents later? 1 Answer

Randomize NavMeshAgents path finding with same destination 1 Answer

how to stop agent when target is unreachable unity 1 Answer

Reasons an NavMesh Agent.isStopped might be set to True? 0 Answers

Making NavMesh areas? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges