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
1
Question by scadl · Mar 22, 2013 at 06:13 PM · navmeshnavmeshagent

Can't get NavMeshAgent move. NavMeshAgent ignores destination property

Hi! I'm using Unity 4.0.0f7. Now, I'm trying to be familliar with NavMeshes and NavMeshAgents. I created a simple plane, made it Navigation Static, Baked it. Created Cube, added NavMeshAgent to it. Attached a script:

 public var target:Transform;
 
 function Update () {
 
 GetComponent(NavMeshAgent).destination = target.position;
 Debug.Log(GetComponent(NavMeshAgent).destination+" "+GetComponent(NavMeshAgent).pathStatus+" "+target.position);    
 }

After first unlucky try, I've added to the script this construction: Debug.Log(Debug.Log(GetComponent(NavMeshAgent).destination) into Update() function. Log says that navmesh totaly ignore my "GetComponent(NavMeshAgent).destination" construction.

"target" is simple capsule, placed on the opposide side of plane. "pathStatus" says "PathComplete".

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

7 Replies

· Add your reply
  • Sort: 
avatar image
6

Answer by twobob · Sep 17, 2014 at 07:10 PM

In my case it was simply that the transform of the target was actually just outside the "Valid Y range" for the destination to "snap" to the NavMesh.

No easily discernible warning is offered in this instance. If the agent was too far from the mesh this would cause a: "SetDestination can only be called on an active agent that has been placed on a NavMesh." when invoking a NavMesh related function ('SetDestination' in this example). However there is no immediate: "SetDestination can only be called on a position within /n/ of the NavMesh.", it simply silently fails. Caveat discipulus!.

Not sure how wide a range that is yet, looks to be about "+-12" just on basic testing.

Hope it helps someone else save some time. There are some helper functions to determine valid mesh points that I also have not explored. That too might be a sensible wrapper for this call.

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
4
Wiki

Answer by scadl · Mar 23, 2013 at 10:42 AM

Hello to everyone! I've finally figure out whats wrong! But I had never imagine, that this coud be reason! So when you Bake NavMesh from your geometry, there are some parameters. In "General" part, there are two parameters: "Radius" and "Height". So, this parameters have nothig with NavMesh generation! Instead this parameters LIMITS NavMeshAgents, to work with this NavMesh. So If you want, that your NavMeshAgents travel over this NavMesh, you should place "Height" and "Radius" of the smallest of your NavMeshAgents into this NavMesh parameter before Baking.

Comment
Add comment · Show 1 · 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 jay3sh · Nov 30, 2018 at 07:25 PM 0
Share

You are correct, I had the same problem. But ins$$anonymous$$d of making the Nav$$anonymous$$esh bake settings for radius and height smaller, I increased the size of my agent. It had to be small, so I kept the small mesh visible and parented it to a cube of big enough sizes and disabled that cube's $$anonymous$$eshRenderer. Did the trick. Thanks.

avatar image
1

Answer by Ghikya · Aug 08, 2016 at 02:17 PM

Also sometimes when you play with NavMeshAgent speed, if you set it to 0 then you forget to set it back to a bigger value, in this case setDestination simple will not have any affect. So you should check this at first before checking other solutions.

Comment
Add comment · Show 1 · 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 clamchoda · May 12, 2017 at 12:36 AM 0
Share

Thank you sir. I have been messing with this on a few occasions! Was indeed the speed.

avatar image
0

Answer by BLarentis · Mar 22, 2013 at 08:07 PM

Hello, try to create an C# script and use this code:

 public GameObject target;
 
 // Update is called once per frame
 void Update () {
 
     

 this.gameObject.GetComponent<NavMeshAgent>().destination = target.transform.position;
     
 }

put the script in your Cube agent. I used this code here and it worked. If this dosen't work, you might have a problem with something else. If this work, you might need to check out how to access your NavMeshAgent component with Java script. Hope this helped you! Take care.

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 scadl · Mar 22, 2013 at 09:34 PM 0
Share

Sorry, I'm not advanced C# user, so I pasted your example like this:

 using UnityEngine;
 using System.Collections;
 
 public class NewBehaviourScript : $$anonymous$$onoBehaviour {
     
     public GameObject target;
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
     void Update () {
         
         this.gameObject.GetComponent().destination = target.transform.position;
     
     }
 }

But compiler Says:

Assets/NewBehaviourScript.cs(16,33): error CS0411: The type arguments for method `UnityEngine.GameObject.GetComponent()' cannot be inferred from the usage. Try specifying the type arguments explicitly

String 16, is the string with main construction, and column 33 is where "destination" placed

avatar image scadl · Mar 22, 2013 at 09:35 PM 0
Share

First - thanks for answer. Second - no, even this script doesn't work...

Attaching my Demo Project. The problem is in "scene2". This is Unity4 project. If you can, please check it, and tell me, whats my mistake? http://www.mediafire.com/?cq5q5ayiww56ia9

The project are clean. The are some simple models from $$anonymous$$aya and Sketchup, but they are in "scene1"

avatar image BLarentis · Mar 22, 2013 at 09:44 PM 0
Share

This site made an error with the format of my code, the correct code linde inside Update is the one inside the image attached. Take Care.alt text

captura de tela 2013-03-22 às 18.46.04.png (22.1 kB)
avatar image scadl · Mar 22, 2013 at 09:49 PM 0
Share

Yes, I corrected code to exatly this. But it's still doesn't work...

avatar image
0
Wiki

Answer by scadl · Mar 23, 2013 at 12:47 PM

Also, if you're NavMesh Baking some sort of huge or extra scaled landscape, don't forget to tune "Width inaccuracy %" and "Height inaccuracy %", because they are controls how much diffrence can be between start point of your agents and destination!

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
  • ›

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

17 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

Related Questions

Navmesh Path is shown even between disconnected regions.? 0 Answers

Lack of Bi-Direction OffMeshLinks for Jumping Up? 0 Answers

Instantiated objects at beginning of runtime are messing with the pathing for my NavMesh. 0 Answers

Find the nearest location and move to a target outside Navigation Mesh? 1 Answer

NavMesh Agent glitches on navmesh edges 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