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 RickTick · Aug 03, 2012 at 08:30 PM · navmeshnavmeshagentloadleveldontdestroyonload

Nav Mesh SetDestination can't be called

Hi,

I have a problem with Nav Mesh. There are two scenes, the first leads into the second.

In the first scene is:

  1. A Character with a Nav Mesh Agent, and a second script from where I set the destination

  2. A walkground with a baked NavMesh

  3. A DontDestroyOnLoad() on the character and a trigger with Application.LoadLevel()

In the second scene:

  1. Another Nav Mesh

  2. A starting point object to which the undestroyed cahracter from the first scene is set, right on the Nav Mesh

When I play it, the first scene works great, the character is navigating through the entire scene. But when I come to the second scene and I click on the walkground I get this message:

 "SetDestination" can only be called on an active agent that has been placed on a NavMesh.
 UnityEngine.NavMeshAgent:set_destination(Vector3)

I have no idea what's the issue. I checked if the component is active, and it's active for sure. Also the character is just above the Nav Mesh.

Here is the code snipped, where the destination is set:

 if(hit.collider.tag == walkTag){ 
 

  print(GetComponent(NavMeshAgent)); //prints YES, IT HAS AN AGENT
  print(GetComponent(NavMeshAgent).active); //AND YES, IT IS ACTIVE
  GetComponent(NavMeshAgent).destination = hit.point; 

 
 }

Any advice?

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

3 Replies

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

Answer by Reapazor · Aug 13, 2012 at 03:45 PM

I've got the same fun little issue :) I'll post here if I solve it.

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 RickTick · Aug 13, 2012 at 06:39 PM 0
Share

I solved it for now, but I don't know why it works. ^^

But try this: Extend the new Nav$$anonymous$$esh to the position where your player position ends in the last scene.

I think the problem is, that the second scene is loaded, then the Nav$$anonymous$$esh checks if there is a player positioned on it and then your new player position is set to the new position on the Nav$$anonymous$$esh. But when the last step happens it's already to late, Unity thinks your player is not positioned correctly.

Try it and let us know if it is in fact the problem. :-)

avatar image Reapazor · Aug 13, 2012 at 06:41 PM 1
Share

You are correct in the load order issue :) Hey Unity!! how about some way to override all this and manually set a navmesh :)

avatar image
1

Answer by diekeure · Apr 23, 2013 at 06:32 AM

I have the same issue, but it's not possible for me to extend the navmesh... Any other possible solutions?

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
0

Answer by Homeship · Jun 17, 2018 at 08:23 AM

[Solution for your problem is here][1] [1]: https://docs.unity3d.com/540/Documentation/ScriptReference/NavMeshAgent.Warp.html

But I'm still fighting with NavMesh. 1) I 've baked NavMesh 2) I've active NavMeshAgent 3) Rigidbody is kinematic 4) GameObject with NavMeshAgent is placed in design-time and doesn't use any versions of transform.position =...

Still have a ""SetDestination" can only be called on an active agent..." error ((

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

10 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

Related Questions

NavMeshAgent Rotate With Model 0 Answers

NavMeshAgent don't move 0 Answers

CalculatePath often returns wrong results 0 Answers

Player's last location as a Transform 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