- Home /
A* Pathfinding Project Y-axis movement, help.
I'm using a PointGraph from the A* Pathfinding Project to manage movement in my game. My objects moves fine until it gets to the blue dot. When it hits the blue dot it'll move back and forth along the green line. It never changes it's y value to move up and continue along the red path. I'm using the AIPath Script that comes with the project. Any ideas what I need to do to get it to finish following the path?
Answer by Cherno · Sep 22, 2014 at 11:32 PM
I assume that the actual path that you see in scene view is leading from the green point diagonally up towards the next one that is lying on the next level? If so, it depends on how the object actually changes it's position.
If it uses physics or physics-like behavior, like a Character Controller, then it's collider will probably get blocked by the side of the next level. If you want it to "jump" or climb up, you would have to script custom behavior.
For example, you can check if the y difference between the current waypoint and then exdt one is above a certain value, and if yes, apply force upwards as soon as it hits the side wall of the next level.
You could also check this periodically so it will also jump over any obstacle between itself and the next waypoint, even if both waypoints lie on the same level.
A word of note: Pointgraphs are not designed for tile-based terrain with a lot of nodes. It's more for things like patrol routes or vehicles moving along a street on a fixed path. Too many nodes will slow the game down to a crawl. Unfortunately, the A* doesn't currently support hex grid graphs as far as I know.