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 WhyAmIDoingThis · Feb 25, 2013 at 10:24 PM · pathfindingpath

Find best path to closest edge of model

Edit: See TL;DR below.

I'm using the A* Pathfinding project to move a unit from point A to a building, using the buildings transform.position. This works, and consistently the algorithm comes up with the same path. Unfortunately, that path for some reason wanders through some obstacles to approach the building from the FAR side of it's model. It would produce a shorter path if I could give it a target Vector3 on the closer edge of the model.

I believe I could do this easily by casting a ray from my unit to the building model, and returning the point at which I hit the model, but that point is not necessarily always the closest point pathing wise, though it is in this particular case.

Has anyone encountered this before? Is there a best practices I should be aware of for this situation?

I will eventually need to do pathing for 1-200 units at a time, so I'm hoping to avoid testing paths against all four corners of the building, or something like that.

Thanks!

TL;DR: I think I can simplify this question.

Picture a building with a transform.position of (5,0,5). The actual dimensions of the building are 10x0x10, meaning the bottom left corner is at 0,0,0 and the top right corner is at 10,0,10. I'm using the transform.position as the target coordinates, but there is a collider (Building model) at a minimum 5 units away, and at worst, roughly 7 units at the corners.

I would like to determine the closest path to ANY part of the building, not necessarily the center. This image might help.alt text

s.png (4.8 kB)
Comment
Add comment · Show 1
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 nsxdavid · Feb 25, 2013 at 10:54 PM 0
Share

Your problem isn't stated very clearly. Perhaps a picture is worth a 1000 words?

1 Reply

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

Answer by steakpinball · Feb 27, 2013 at 11:55 AM

Collider.ClosestPointOnBounds sounds exactly like what you're looking for. It won't do the pathfinding, but it will give you the nearest point.

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

11 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

Related Questions

A* Pathfinding, destroying a path once it has reached its end 0 Answers

Is it possible to store NavMeshAgents paths and assign them to other NavMeshAgents later? 1 Answer

Is it possible to assign a custom path to a NavMeshAgent? 0 Answers

How do I get my patrolling enemies to go back to the patrol point they had not gotten to because they chased the player? 0 Answers

Pathfinding help 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