Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by wyldeboyy · Dec 15, 2014 at 09:30 AM · c#navmeshnavmeshagent

Enable/Disable the NavmeshAgent programatically?

Is there a way to uncheck the Navmesh Agent check box programatically? Can it be done using a NavMeshAgent object?

alt text

Change to:

alt text

enable.png (14.3 kB)
^cdba32e2c5ae2ed507d9b1a11137b27d26c5ce0885a628c92b^pimgpsh_fullsize_distr.jpg (14.2 kB)
Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
8
Best Answer

Answer by Mmmpies · Dec 15, 2014 at 10:24 AM

Not go access to Unity at the moment but if the script is attached to the character you want to disable a component on then in c#

 gameObject.GetComponent<NaveMeshAgent>().enabled = false;

JS

 gameObject.GetComponent(NavMeshAgent).enabled = false;

if the script isn't on the character the you need to reference the gameObject it's on with Find or FindGameObjectWithTag.

The above should work just replace gameObject with whatever variable use store the result of the Find.

Like I said not got access to Unity so sorry for any typo's!

Comment
Add comment · Show 4 · 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 wyldeboyy · Dec 15, 2014 at 12:17 PM 0
Share

Thanks man that's the one I've been looking for! Great help!

avatar image Mmmpies · Dec 15, 2014 at 01:15 PM 0
Share

No problem amazed there were no typos as the rest of the post is littered with them. Typing on a phone! You can use the same for any component of a gameObjet so if you have a script called health with a public method called TakeDamage that takes a float use get component for health and replace enabled with TakeDamage ( float 5f); and youve passed 5 point of damage to it.

avatar image NihkValentine Mmmpies · Apr 14, 2017 at 12:13 AM 0
Share

how come it doesn't work for me? unity 5? cant seem to remove navmeshagent component.

avatar image Vercinger NihkValentine · Apr 22, 2017 at 01:22 PM 1
Share

Have you tried using UnityEngine.AI.Nav$$anonymous$$eshAgent ins$$anonymous$$d of just Nav$$anonymous$$eshAgent?

  gameObject.GetComponent<UnityEngine.AI.Nav$$anonymous$$eshAgent>().enabled = false;
avatar image
0

Answer by Reals · Dec 13, 2017 at 07:57 PM

agent.enabled = !agent.enabled

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

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

7 People are following this question.

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

Related Questions

Finding Closest Object Through Navmesh,Identifying Which Object Is Closest on NavMesh 0 Answers

is it possible to use navmesh on flying character and target ? 0 Answers

My ai is getting stuck when there is a lot of them 0 Answers

Prevent NavMesh from Moving Diagonally? 1 Answer

Unity pathfinding - Comparing 2 paths? 2 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