1
\$\begingroup\$

I've gone through A* pathfinding but could find anything on this. What I'm looking for is pathfinding for something kind of like a super smash bros level with different platforms. Can anyone point me in the right direction?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

This entirely depends on the nature of the game's platforms. Can you jump through them from below? Can you drop down through them while standing? Can you pass through them while falling without landing? Can an NPC jump/glide/accelerate in a specific direction mid-air?

These are all questions you should be asking when implementing your pathfinding algorithm.

All in all, A* is pretty much applicable to all pathfinding. It's a very, very abstract algorithm, and all it requires is some sort of system of points or nodes in one form or another (polygonal vertices/edges/faces all work great for representing these) with some way to determine the "cost" of moving from one node to the next.

Given that the platforms will likely be flat surfaces, with no third dimension of movement, you could easily use a system of points that define the borders of each platform (left and right), and treat everything between those points as "walkable." From there, you just need to get your NPC to the goal location (which is decided by the AI behavior more than the pathfinding algorithm).

If you want to define AI behavior to be, say, "melee" aggressive, you'll likely want them to get as close to the player (or enemy, if the NPC is friendly) as possible, so they can attack them.

If you want to define AI behavior to be "ranged," you will likely want to find a position where the NPC is "safe" (distanced) but has a clear shot at the target.

The most efficient way for an NPC to detect these sorts of "hot spots" for target finding would be to pre-program them into the node map, itself.

For example, many NPCs in modern games know how to take cover behind obstacles, in combat. This is generally not because the AI is taught how to detect if an obstacle has a large enough bounding box to be used as cover, but rather because there is a pre-defined node (or, in fancier implementations, a polygon covering an area that is "acceptable to take cover at") told them that they should go there, and they likely detected that the player had too clear a shot at them (either by raycasting to the player's line of sight, or by the player's relative position with respect to the current position of the NPC).

AI behavior is full of quick little hacks like this that can all combine to make a fully functional, believable NPC.

\$\endgroup\$
1
  • \$\begingroup\$ Incredible answer. Definitely got me going in the right direction. I ended up just dropping A* and went with a combination of edge triggers and jump triggers. It's not perfect yet but I think I'll be able to get something I'll be satisfied with this way. \$\endgroup\$
    – user44763
    Apr 28, 2014 at 19:18
0
\$\begingroup\$

I would have placed invisible object that when the NPC collide they change direction. You will get pretty far with that.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .