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 2-Zons · Nov 25, 2015 at 05:57 PM · navmeshnavmeshagentnavigation

Nav Mesh Agent destination not lining up with actual target.

I've recently converted my movement script for NPC's in my game from manually moving their rigidbodys to letting the navmesh agent move them. I am simply using the .SetDestination method of the agent. I've also just set the destination property. In both cases the destination doesn't line up with the actual target I'm wanting them to go to.

I am setting the destination to the transform.position of another gameobject. When I debug.drawline to the transform.position of the target, and the agent.destination I get two different lines. The farther away the target is the bigger the offset.

Any ideas?

Comment
Add comment · Show 6
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 2-Zons · Nov 25, 2015 at 09:00 PM 0
Share

I've found part of the problem. I had my base gameobjects scaled up. I re-made all my prefabs so that the base gameobject with the navmesh agent was at a scale of 1,1,1 and now the offset is much smaller but there is still an offset. Also when I place effects at the navmesh agent objects transform.position they are also not lining up.

Are these bugs with navmesh?

avatar image insominx 2-Zons · Nov 25, 2015 at 09:21 PM 0
Share

Navmesh destinations will always get clamped to actually be on the navmesh so if your target gameobject has its position floating in the air above it, then Unity will search for the closest place on the navmesh which may in some cases not be what you want. Do you have a screenshot?

avatar image 2-Zons insominx · Nov 26, 2015 at 12:42 AM 0
Share

That's not the problem. $$anonymous$$y game is essentially 2D, top down, X and Z only. All objects are on the same plane.

avatar image 2-Zons · Nov 26, 2015 at 01:01 AM 0
Share

alt text alt text Here is a couple of screenshots. The red line is a debug.drawline from the agent's transform.position to the agent.destination. The black line is from the agent's transform.position to the target's transform.position. When i set the destination I give it the target's transform.position but this is what it turns into. There is a difference in the Y which but the X and the Z are also offset.

navmesh-problem-capture.png (367.7 kB)
navmesh-problem-capture-1.png (165.2 kB)
avatar image insominx 2-Zons · Nov 26, 2015 at 01:06 AM 0
Share

Agent destination aside, why would the agent's transform.position be in different places for each set of lines? They should be the same value right?

avatar image 2-Zons · Nov 26, 2015 at 01:11 AM 0
Share

To eli$$anonymous$$ate the possibility that a difference in Y was causing the problem I've tried just passing the X and Z to the destination and setting the Y to the same as the Y of the navmesh. The result is the same.

1 Reply

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

Answer by 2-Zons · Nov 27, 2015 at 04:04 AM

I have found the problem. The target in question is a nav mesh obstacle. When given a destination in an inaccessible area it picks a location close to the destination but not right at it. When i give a destination of an object that is not an obstacle they line up perfectly.

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

36 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

Related Questions

Problem with NavMesh 0 Answers

Navmeshs and Trees 1 Answer

NavMeshAgent not teleport on y axis 0 Answers

Click to move NavMeshAgent Script not working... please help! 1 Answer

Need help with Nav Mesh Agent getting "stuck" at high speeds 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