- Home /
Path Finding With Different Elevations
So, given that i have that i have an enemy who is on a plat form 5 meters higher than the player, and has a ramp going down to player elevation... When i path find, how do i check to see if the drop off of a platform, in this case 5 meters, is greater than 3 meters (or whatever height) and there is another way to get to a position (in this case, the position of the player).
I basically want the enemy who is on said platform to walk down the ramp, instead of walking off the side of the 5 meter high platform (which would cause fall damage). Also, if no other path exists for said enemy to go down that is safer than jumping, he should jump.
Any help is appreciated <3
Answer by Fattie · Oct 15, 2012 at 08:13 AM
quite simply,
have a point we'll call "B" at the bottom of the ramp.
now also have (say) three points (F, G, H) which are where HE WOULD LAND, IF HE JUMPED.
so, forget about where ther guy is standing (on the platform).
path-find separately from B, F, G, H.
make an intelligent decision based on whatever factors you want.
(obviously, once you decide, have him separately move ro B.F.G or H, and then turn on your pathfinding-whatever algorithm for the rest of the travel.)
This is very common, you have to "stage" your pathfinding.
I get concerned generally when beginners get all "a-star!" ............ often it's better to step back .. is there a simpler way?
So, I hope it helps.
It's funny, what you're doing is EXACTLY like GPS engineering in europe
(ie, you have to consider the stupid channel tunnel and that fucking long storebeltsbronenwhatever brucke as special cases that poop all over your otherwise elegant algorithms.)
Hmm, so... really i would have to have a point preset at every ramp/staircase in the entire map?
There would definitely be thousands of ramps or stairs or other paths that would be easier for an NPC in my game to travel rather then going another route. $$anonymous$$y game consists of several islands that are all quite large. So, i guess created different versions of a type of ramp, stair case or whatever each with a point on it would work as long as i reuse it... Otherwise, the estimation of time I'd have to put in would be much longer than previously perceived.
hiya! FTR, I struggle to see what the game would be like. note that pathfinding algorithms just won't work with that many parts.
YES on what you say about putting a script under each ramp. Good luck!
I encourage you to open new separate questions on this one, if you have more interesting issues. You'd have to explain more exactly what the hell the game is, what it looks like, how you made it. Good luck!
The script thing about "This is a ramp" why not using a tag ins$$anonymous$$d. You could then retrieve all ramps faster with FindGameObjectsWithTag.
A script saying "I am a ramp" would need find all game objects then reach their script and then compare the string. Reaaaally long process.