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
1
Question by fred_gds · Jan 19, 2016 at 03:59 PM · distancewaypointwaypoint systemreset-position

Search very large waypoint-like system

Hi,

I am looking for a way to approximately find the closest waypoint to my player without having to check all the waypoints (as it would take too long).

Our system has half-million waypoints and relates to a traffic system

I have the waypoints stored as a list of Vector3 and I would prefer not to loop through those until I find one that is inside a close distance.

So I thought I could maybe lay some kind of Grid System over the scene to structure it into small pieces, but I hope someone might have a smarter solution to it :)

Best regards,

Fred

Comment
Add comment · Show 3
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 Owen-Reynolds · Jan 19, 2016 at 06:45 PM 0
Share

One of the standard grid systems used to organize 3D points is a OctTree. That should take you to other similar solutions (I believe an OctTree is for 3D -- probably a similar thing for 2D.)

avatar image Fattie Owen-Reynolds · Jan 19, 2016 at 06:49 PM 0
Share

quite - an OctTree or some sort of spatial hashing. (i wouldn't even know how to begin with 1/2 million points.)

my guess is, it could be OP is making some basic flaw in approach; for example it could be OP is charting out "every few inches" of even straight roads, or something like that, rather than (say) using some sort of higher-level representation (indeed, as is done in GPS/mapping software - one way or another).

avatar image fred_gds Owen-Reynolds · Jan 19, 2016 at 07:14 PM 0
Share

Thanks Owen. A OctTree was what I had in $$anonymous$$d (just did't remember the name).

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Fattie · Jan 19, 2016 at 04:36 PM

The following answer only relates to typical games with typical waypoint systems per your earlier question edit.

With "half a million" waypoints, you are talking about perhaps a GPS-like system or some sort of other novel structure, which is not really a ordinary game-like "waypoint" system, which I assumed you meant - sorry about that

It wouldn't really work like an everyday "waypoint" system in a game

It sounds like a fascinating project and you'll have to totally get in to spatial hashing

I don't think it would be possible to "just give" a solution as it would be novel custom engineering based on your overall concept. Cheers


First, note that it will not take too long :)

Computers are incredibly fast - how many waypoints do you have? If less than a few thousand you won't even notice it. Unless something is screwed-up.

Secondly this is an incredibly well-explored area in computer engineering. And it would be ridiculous in most situations to write spatial hashing (what you hint at in the "many squares" comment) yourself from scratch.

You can't really use unity or any game engine without a spline package,

so get something like SuperSplinesPro and the function you need ("get closest waypoint") is completely built-in, you know?

Footnote - - I mention SuperSplinesPro particularly; that traditionally was the very best spline package. Sadly it is now unsupported (no updates for 2 yrs) so, one can't realistically buy it -- but anyway find the spline package (free or paid) you like and use that for the issue at hand.

Comment
Add comment · Show 6 · 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 fred_gds · Jan 19, 2016 at 04:44 PM 0
Share

Thanks for your answer, but I ask because it takes too long :). I am making a game for mobile devices and have around 500.000 waypoints for my traffic system. So looping through them kind of affects my framerate as I have a lot of other stuff going on at the same time and I don't want to break my physics model (as I decreased the maximum overhead I allow for those calculations).

avatar image Fattie fred_gds · Jan 19, 2016 at 04:51 PM 0
Share

O$$anonymous$$ I have edited the question for you. Hope you find a good engineering approach. You must surely have some structures associated with the data (roads, suburbs, type of surface or whatever) so your solution would relate to that, and some sort of spatial hashing technique. Enjoy!

avatar image fred_gds Fattie · Jan 19, 2016 at 04:59 PM 0
Share

Yeah the data is attache to a road based environment. Thanks for the idea of spatial hashing. I'll definitely take a look at that :)

Show more comments

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

33 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

Related Questions

What is a WaypointCircuit? How I make one? 2 Answers

how to make moving gondolas in unity? 0 Answers

AI Waypoint rotate problem 0 Answers

what's wrong with my waypoint placer script 0 Answers

Why the loop in waypoints in not working when set to true? 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