Hey guys,
today I've come with a sort of "problem". Do you know those A* pathfindings? Yeah they work pretty well, but how can you make a GPS Navigation in a game (3d) from point A and B?
My "programmer brain" tried a bit, and came to the hypothesis of a hashmap with keys being the origin and destination, then there would be every single possibility of paths from every waypoints.
Imagine the following: you have a house with a corridor (you are on the corridor), and you have 4 rooms, 2 in each corridor side. If you want to go to the furthest room it will check that hashmap with the current position you are (or the last checkpoint) and see where it matches the furthest room waypoint, and enable the "direction path" objects on the way...
Is this any good? How would you do it?
GPS Navigation Directions? (3D)
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: GPS Navigation Directions? (3D)
It depends on what you mean by 3D. If your characters are floating through the air and can actually move in any direction, that will be a bit tougher but I bet someone out there has tackled it before. If your characters are under the effect of gravity and can't just decide to go straight up into the air, then the typical A* will work fine. You just divide the ground in your game into a 2D array, mark which ones cannot be traversed through (walls, fences, etc.) and then run that through the A* algorithm. It won't matter if they are going up hills, or walking along raised blocks, or anything like that since they are still at a location in the 2D array. If there are multiple levels of height, such as different stories in a building or tunnels underground, just use the current level that the player is on as the ground to divide up into the 2D array.
The indelible lord of tl;dr
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: GPS Navigation Directions? (3D)
So the answer might be to look at this problem in a 2D prespective?
I can see it, but I'm afraid this would be a pain in the butt to "re-invent" :/
I can see it, but I'm afraid this would be a pain in the butt to "re-invent" :/
- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: GPS Navigation Directions? (3D)
What are you using? I would assume since this is 3D you are using some kind of engine, and from your previous posts I would guess Unity, right? Do they not have a solution for this built-in? That would surprise me.
The indelible lord of tl;dr
- vitinho444
- Posts: 2819
- Joined: Mon Mar 21, 2011 4:54 pm
Re: GPS Navigation Directions? (3D)
(Again, I'm sorry for the delay on the reply -.- Don't know why the "See Latest posts" link didn't include your reply.. )
I am using Unity yes, and I don't think it has a 3d navigation system built in... At least that I know of. What I did was to create a 3D arrow and do the navigation with it. Like this:
It's a little rudimental, but I guess it's fine for the purpose...
I am using Unity yes, and I don't think it has a 3d navigation system built in... At least that I know of. What I did was to create a 3D arrow and do the navigation with it. Like this:
It's a little rudimental, but I guess it's fine for the purpose...