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 shokri · Nov 24, 2015 at 04:30 PM · navmeshnavmeshagentpathfindingcontroltraverse

Is there any way to cancel an OffMeshLink while the agent is on it already and waiting for it to be completed?

Hi, is there any way to cancel an OffMeshLink while the agent is on it already and waiting for it to be completed?
Well, I know that my question is vague so please let me describe it through an example.

OK here is my scenario: I have two rooms (room A and room B) which are connected via a door. Also I have a keypad on the wall of room A which unlocks the door. I’ll find this keypad later, using a script that is attached to the door. Finally I have an agent that I want to move him from room A to room B. The door may be locked, so the agent should check the door and if it’s locked, he should change his way to the keypad, which is on the wall, to unlock the door and then continue his way through the door to reach room B.

Here is my approach: I’ve connected both rooms NavMesh together via an OffMeshLink. Tending to move the agent, I set the destination to room B. Not to mention that I’ve turned off NavMeshAgent.autoTraverseOffMeshLink so I can handle the movement myself. I check if there’s any OffMeshLink through the path using NavMeshAgent.nextOffMeshLinkData. This way I can access to the door and its script to find out if it’s locked or not:

  • If the door isn’t locked, then on the moment of reaching the door, the agent will pass through the door simply (I’ll complete the OffMeshLink after my movement using NavMeshAgent.CompleteOffMeshLink).

  • If the door is locked, then the agent will change his way toward the keypad (I’ll reset the destination to the keypad position). He will invoke the keypad to unlock the door and then continue his way toward the door and finally the other room (I’ll reset the destination back to room B).

Now the problem is that if the agent is near the OffMeshLink already when I set the destination to room B, then NavMeshAgent.nextOffMeshLinkData won’t get me valid information regarding the OffMeshLink, because he’s currently on the OffMeshLink and there isn’t any other OffMeshLink along the way. However, NavMeshAgent.isOnOffMeshLink is false unless I set the destination. It means there’s no way for me to find out about the door status before reaching the OffMeshLink. In this situation the agent will freeze until I complete the OffMeshLink, which is awkward (Passing through an unlocked door?! It’s ridiculous).

I thought maybe I’d to cancel the OffMeshLink and set the destination to the keypad, but unfortunately there is no way to cancel an OffMeshLink while the agent is waiting for it to be completed.

What’s the solution? Should I follow another approach? I’m thinking of using two OffMeshLinks instead of one and put each one on one side of the door, but it seems to dirty. Any help would be appreciated.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

Answer by zakirov78 · Jan 09, 2017 at 07:49 PM

NavMeshAgent.Warp to the same position helped me to reset isOnOffMeshLink flag.

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 SlySIy · Jul 12, 2018 at 03:48 PM 0
Share

Wow nice trick dude! Thanks a lot, you saved me so much time! :)

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

37 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

Related Questions

[Unity .3.03f] NavMeshAgent stops after rebaking NavMeshSurface 0 Answers

NavMesh agent moving to unassigned target 1 Answer

Farthest Reachable Destination 0 Answers

Second NavMesh Surface refuses to cooperate: Failed to create agent because it is not close enough to the NavMesh 0 Answers

Is there a way to modify my script a path, before setting it to a NavmeshAgent 0 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