Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 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 /
This question was closed Oct 06, 2020 at 03:53 PM by Cazual for the following reason:

Other old

avatar image
12
Question by Cazual · Aug 04, 2013 at 11:41 AM · navmesh

"SetDestination" can only be called on an active agent that has been placed on a NavMesh.

Whe I create a prefab with a navmesh agent in it, and drop it in a scene, I can programmatically set the destination with this code as a specific point in the game, and it goes to the destination.

Debug.Log ("Set Destination"); meshagent = GetComponent(); meshagent.destination = target2.position;

however if i spawn using an instantiate with the prefab I get the following error when setting the destination and it does not go to the destination

"SetDestination" can only be called on an active agent that has been placed on a NavMesh.

Anyone any ideas

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

16 Replies

  • Sort: 
avatar image
50
Best Answer

Answer by chrwoizi · Nov 11, 2016 at 08:31 AM

If you create a NavMeshAgent and set its position via transform.position=... and then try to SetDestination, it fails because the NavMeshAgent did not recognize the position change and does not know that it already is on the NavMesh. Use NavMeshAgent.Warp instead of transform.position to initialize the position before calling SetDestination.

Comment
Add comment · Show 8 · 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 zeyadJY · May 17, 2017 at 09:13 PM 0
Share

Thank you very much, you have the correct answer, I just got the reference to the navmesh agent component and I used warp ( spown Location) and it solved my problem

avatar image satyajitdas · Jun 27, 2017 at 10:35 PM 0
Share

Thanks a lot! This is exactly what was my problem!

avatar image SepraB · Jul 31, 2017 at 01:10 AM 0
Share

I love when people like you try to solve the others problems. Thank you so much!!!

Please, someone, give him infinite points, I don't have nor one point.

avatar image Eco-Editor · Aug 15, 2017 at 07:42 AM 0
Share

Hi @chrwoizi where in code should the Nav$$anonymous$$eshAgent.Warp be called? Can I call it in start? In my scene I enable and disable rooms. So once the room is enabled it gives me this error

avatar image navidhaghighi · May 27, 2018 at 02:21 PM 1
Share

will you please mark this as correct answer?

Show more comments
avatar image
22

Answer by rasoulcarrera · Jan 18, 2014 at 11:27 AM

I had the same issue... In your scene click on a mesh or train and then in Window tabs select navigation... Now u can see navigation layout beside the inspector... Just in bake tab of navigation click the bottom button that says Bake... And you're done

Comment
Add comment · Show 5 · 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 petitmottin · May 04, 2014 at 11:26 AM 4
Share

Just in bake tab of navigation click the bottom button that says Bake

Thanks rasoulcarrera, it works fine for me !

avatar image rizzeclair · Nov 29, 2016 at 11:23 AM 0
Share

thanks for solution .. this work .. nice (y)

avatar image danishsaleem167 · Aug 17, 2018 at 10:58 AM 0
Share

You just solved it thanks bro

avatar image Baria · Dec 01, 2018 at 04:40 PM 0
Share

Thank you so much that worked great for me... u saved my life u have no idea

avatar image ffxiangyu · Nov 21, 2019 at 11:54 AM 0
Share

thanks bro, it works for me

avatar image
11

Answer by sandbaydev · Apr 10, 2018 at 04:45 PM

5 year old issue, but since I was having this problem today I thought to add to this.

Make sure you use "humanoid" agent type. If you use custom type, you need to use NavMeshSurface by Unity.

See also here: https://issuetracker.unity3d.com/issues/custom-navmesh-agent-type-causes-an-error-failed-to-create-agent-in-the-console

Comment
Add comment · Show 3 · 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 fametune · Jul 15, 2018 at 09:59 AM 0
Share

Thank you, this saved me some headache

avatar image AlharbiSunds · Aug 05, 2020 at 02:29 PM 0
Share

thankful for your thought !

thank you

avatar image jandd661 · Aug 22, 2021 at 02:49 AM 0
Share

This was my issue. Thanks for adding it!

avatar image
5

Answer by HappyLife · Jul 05, 2015 at 06:57 AM

There‘s a possibility that the value of Agent Radius or Agent Height was set too small to not make Agent move;

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
3

Answer by Nexonity · Aug 04, 2013 at 12:56 PM

I had the exact same problem but i solved it by moving the spawning position down a little bit so the navmesh agent spawned on the NavMesh, That way it did work for me.

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 MooOooN · Mar 13, 2015 at 05:47 AM 0
Share

Worked for me too. Thanks!

avatar image Nikhil11 · Sep 28, 2017 at 11:02 AM 0
Share

Thanks Its Working

  • 1
  • 2
  • 3
  • 4
  • ›

Follow this Question

Answers Answers and Comments

51 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

NavMeshAgent not fully reaching destination, thus it won't delete itself when it gets there 1 Answer

Question on Setting/Building Navmesh / Navmesh Agent Path 0 Answers

How to add variables to Components (Nav Mesh Agent)? 0 Answers

Problem getting player to switch navmesh layers 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