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 /
avatar image
0
Question by digzelot · Jul 09, 2018 at 10:46 PM · navmeshagent

Why does my navmesh agent take longest path? (VIDEO)


VIDEO


I'm trying to figure out why my navmesh agent would rather take the longest path to an object even if hes standing right next to it...


Does anyone know why this would be happening?

This is the navmesh after the first gate is opened


alt text


If I go to that left most gate first, he just opens it like the other, but then if I go to the top gate, he does the same thing... runs through the first opened gate to the outside of the gate he should have just ran straight to... no idea why


UPDATE: The gates have a Navmesh Obstacle on them: Per the docs "The Nav Mesh Obstacle component allows you to describe moving obstacles that Nav Mesh Agents should avoid while navigating the world" - I'm using a navmesh obstacle to alter the navmesh after a gate is opened - disabling the navmesh obstacle fixes the behavior - the problem is my player can just run through gates. I can stop movement in the trigger, but am wondering if there is a way to avoid it?

navmesh.jpg (270.4 kB)
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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by NoDumbQuestion · Jul 10, 2018 at 01:29 AM

Because some of area did not have blue area(walkable path)

In navmesh Navigation window(Bake Tab). Change radius of agent from 0.5f -> 0.25f or your agent size. Will fix your problem

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 digzelot · Jul 10, 2018 at 02:50 AM 0
Share

Tried this and it didn't work, I tried going to 0.1 and same issue happens. I updated the video with a new link

also here: video

avatar image NoDumbQuestion digzelot · Jul 10, 2018 at 02:58 AM 0
Share

That far door. Have a range that is too close to the mesh.

When you click the gate. navmesh will find the closest point that is walkable. It will choose that point(the point on otherside of the gate) to go.

I would use SamplePath First. Then see if that point is walkable. Otherwise tell it just to move close to the destination as possible(different than just change final position).

Another option is to make your own path then apply it

avatar image
0

Answer by digzelot · Jul 10, 2018 at 11:53 AM

The easiest solution for this was to manipulate the end point of the destination. I'm still not sure why, but It was like I was getting random results: will the agent open the gate on the correct side or will he run around the map to the other side?


Ultimately I just subtract 1 unit from the path towards the player, so that the destination was always on the side of the fence that the player is on:

 destination = hit.transform.position;
 distance = Vector3.Distance(transform.position, destination) - 1.0f;
     
 moveToPos = (destination - transform.position).normalized * distance;
 moveToPos = transform.position + moveToPos;



Thanks to @NoDumbQuestion for suggesting I build my own path

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

88 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

Related Questions

Navmesh Agent Not placed on mesh? 3 Answers

Graphics Problem and NavMesh Obstacles 0 Answers

Failed to create agent because it is not close enough to the NavMesh 0 Answers

How to prevent NavMeshAgents from colliding when warped to same position? 0 Answers

Why does my navmesh not stop at this wall? (stealth tutorial) 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