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 EF · Apr 03, 2016 at 09:37 AM · ainavmesh

Using NavMesh.Raycast to detect if AI should jump over a gap

In my side scroller game I want my AI characters to freely navigate between platforms, which often leads to jumping. To tell if AI should jump or not, I'm using NavMesh.RayCast to tell if there is gap between navmeshes that is connected with offmesh links. Now, this works well in most cases, but completely fails with navmeshes taht overlap in Y axis(there is walkable platform above another walkable platform). The problem is apparent in pictures below:

alt text alt text

and a code snippet:

  private bool TestJump(Vector3 currentPosition, Vector3 targetPosition)
     {
         NavMeshHit hit;
         bool potentialJump = NavMesh.Raycast(currentPosition, targetPosition + new Vector3(0,0.4f,0), out hit, NavMesh.AllAreas);
         if(hit.hit)
         {
             Debug.DrawLine(currentPosition, targetPosition, Color.yellow, 0); 
         }
         else
         {
             Debug.DrawLine(hit.position, currentPosition, Color.red, 0);
         }
         return hit.hit;
     }
     private void PlotPath()
     {
         if (_pathCache != null)
         {
             var a = _pathCache.ToList();
             for (int i = 0; i < a.Count()- 1; i++)
             {
                 var v1 = a[i] ;
                 var v2 = a[i+1] ;
                 float t;
                 if (!TestJump(v1, v2))
                 {
                     Debug.DrawLine(v1, v2, Color.green, 0);
                 }
 
             }
         }
     }

Am I missing something here, or navmesh raycasting is completely useless when it comes to multi level navmeshes?

Thanks.

navmesh.jpg (60.2 kB)
navmesh2.jpg (73.3 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

0 Replies

· Add your reply
  • Sort: 

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

76 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

Related Questions

Objects dissappear when baked with navmesh 0 Answers

navmesh agent not working after update to 2017.1 3 Answers

How can I enforce off mesh link planning to actually use the link start and end point? 0 Answers

lookAt doesnt work with navmeshagent 0 Answers

NavMeshAgent isn't chasing the player 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