Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by urehelonn · Jun 27, 2018 at 08:13 AM · ainavmeshnavmeshagent

Failed to create agent because it is not close enough to the NavMesh & "SetDestination" can only be called on an active agent that has been placed on a NavMesh.

All the answers I found for the similar problems doesn't fix my headache :(

In my project what I'm trying to do is instantiate lots of worm based on a worm already in the world, and the worm has some simple AI so they can move randomly around. There is an object pooler to recycle the worms so they can be generated again in front of person, and whenever it is called again to be shown at the new position, it has a chance to popup those errors and warning (while some of them are just doing fine).

This is the simple object pool I've got:

 private void Start()
     {
         items = new List<GameObject>();
 
         //add all the objects to the worm mesh pool
         for(int i = 0;i<amount; i++)
         {
             GameObject obj = Instantiate(itemSpawn);
             obj.GetComponent<NavMeshAgent().Warp(itemSpawn.transform.position);
 
             //deactive the object for the start
             obj.SetActive(false);
             items.Add(obj);
         }
 
         InvokeRepeating("Spawns", frequncy, frequncy);
     }

 void Spawns()   //active the object from the worm pool
     {
         //get player position
         pos = player.transform.position;
         
         for (int i = 0; i < items.Count; i++)
         {
             if (!items[i].activeInHierarchy)
             {
                 //generate a random position in front of the player on the plane
                 Vector3 position = new Vector3(Random.Range(-5F, 5F),
                     Random.Range(0.5F, 3.50F),
                     Random.Range(0.0F, 30.0F) + pos.z+0.5f);
                 items[i].transform.Rotate(0,(Random.Range(-90F, 90F)),0);
                 items[i].SetActive(true);
                 items[i].GetComponent<NavMeshAgent>().Warp(position);
                 break;
             }
         }
     }

I tried to add download the navmesh component form https://github.com/Unity-Technologies/NavMeshComponents which helps me none. Also checked the position where the worms are generated, since I set the navmesh surface be really free, big and high, I don't think that this problem is caused by the agent not on surface. Changing on the prefab is also not helpful. Those worms are instantiated form the same gameobject which is already in the world, when the one triggered the problem it won't move as much as its own kind. These doesn't effect much on the game now, but keep getting these errors, I think it's better to be fixed. Hope someone could give me a hand on what is going on...

Comment
Add comment · Show 6
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 tormentoarmagedoom · Jun 27, 2018 at 03:06 PM 1
Share

good day.

Can you post an image of the scene, whewre is the spawn position, the warp position, the navmesh area, how are the agents capsules, how is the mesh baked.

AS more info, more probability to get an answer

bye!

avatar image urehelonn tormentoarmagedoom · Jun 27, 2018 at 08:06 PM 0
Share

Thanks for replying! The instantiation is based on this gameobject: alt text

The agent collider doesn's seem to match the mesh position as well: alt text

catepilliarinfo.jpg (48.6 kB)
agentsize.jpg (12.0 kB)
avatar image urehelonn tormentoarmagedoom · Jun 27, 2018 at 08:08 PM 0
Share

The reply seems only allows two image each, so you will get several replying for this topic, sorry for that... I edited the spawner to make it spawn slower so I can see which has the problem and which doesn't. I find no difference between the data. This is a trouble maker worm: alt text alt text

missedagentlanded.jpg (36.0 kB)
missedagentinfo.jpg (42.7 kB)
avatar image urehelonn tormentoarmagedoom · Jun 27, 2018 at 08:09 PM 0
Share

This is a normal worm: alt text alt text

normalagent.jpg (43.0 kB)
normalagentinfo.jpg (46.6 kB)
Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by tormentoarmagedoom · Jun 27, 2018 at 08:23 PM

Good day.

You are not warping coreectly, you forget to close the getcomponent, look what ypu have :D

 obj.GetComponent<NavMeshAgent().Warp


so is not executing that line, so you are not warping it.

:D Byee

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 urehelonn · Jun 27, 2018 at 09:03 PM 0
Share

LOL I'm gonna try out, did this dumb mistake really bothered me for days. Thank you!

avatar image urehelonn · Jun 28, 2018 at 01:46 AM 0
Share

it's obj.GetComponent().Warp(position); In the code, and it doesn't effect on the functionalities. Also the problem doesn't happened when instantiation, it only happens sometime after the worm need to show up at the new position. Thanks anyway :(

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

207 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 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 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

NavMeshAgent isn't chasing the player 0 Answers

NavMeshLink don't work in correctly in certain area 0 Answers

navmesh agent not working after update to 2017.1 3 Answers

NavMeshSurface or NavMeshAgent agentTypeId can't be changed on runtime 0 Answers

How can I check the destination outside the navmesh? 1 Answer


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