Platform Pathfinding AI

  • Something I have been searching the entire internet is how to efficiently do platform path-finding AI.

    I have coded some very messy code comparing the x and y positions of the enemy and the player to find the player using those conditions bundled with the platform behavior, but it just seems very buggy and inefficient, is there possibly a solution to this issue?

    When just doing horizontal pathfinding, that is fine, but when you start adding the y-axis in the mix as well as obstacles and walls things get very complex quickly.

    I am just stumped

    Thank you!

  • could do it like this

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Lordshiva1948

    Thank you for your input, but I think you miss interpreted what I tried to say, a platformer style game not top down. Here is an illustration of the type of pathfinding I am trying to achieve

    Where the red is the enemy, and green is the player.

    Sure, I could hard code the AI for this specific scenario, but it wont be. As the player can make up the platforms obstacles, walls etc. It is dynamic, not a static level.

  • I think that could be done with just events, without need of the pathfinding behavior.

    The enemy needs to check where the players is, higher or lower, left or right. And then evaluate if there is an obstacle in that direction relative to where it is currently standing on. And then make it choose the path that is unobstructed.

    The enemy should consider if the obstacle can be jumped, and if the player is higher than him whether or not it can be reached.

  • Sargas

    I used the platform behavior to move the enemy around already. Like I have tried to explain above. It worked to an extent, but it is very buggy.

    I had it evaluate if the player is above or below with comparison, and if it was left or right, using comparisons with x and y values.

    What you have, I know what direction to take, but it just doesn't seem the right way to go about it. I have looked all over these forums and there is no sort of platformer based pathfinding.

  • im trialing a dungeon keeper game. AI for imps (dwarfs in my case) has given me the same problem.

    I set a view sprite in front to check collisions, left and right view sprites to check gap openings. (its not a platformer) he might walk a few circles but he'll get there...sigh, im trialing "angled" view spites atm so it wont hit collision until after passing a wall. (turns too quick and doesnt get a straight angle atm)

    if i set a destination for AI via a click he just plows into a wall. sigh, whats the point of a path finder if it sux.

    I trialed waypoints on claimed land, to no avail... seems to cut off and restart..

    Sargas has fine logic, but no programming explanations. might as well have a flow chart saying (decide if want to go to shops) (if yes) (go to shops)...

    my planning is not with jumping however. surely, if all you need is for that sprite to reach its destination, bullet movement to the left, with a everytick position to pin a view sprite. on collision (view sprite, overlap was better) with wall change angle 180' if view sprite overlaps wall(solid) jump (or on "platform jump"ect) . finaly. on destination set bullet speed to zero. or set bullet angle 180' and add the bounce off affect to the bullet, so on returning and jumping against left wall the bullet automatically changes direction during jump.

    note! view sprites must be set to angle themselves based on player direction (or just apply the same ' the AI sprite takes everytick

    i have questions, but i keep getting new problem solving ideas... sigh.. it usually ends up in a messy layout. when i can post things I will show an example... just don't want people stealing it lol.

    ps: i can understand me, if you cant, i can re fraze it and add a screenshot of my example

  • I am having this exact same problem with my own project! I was saddened to find that the pathfinding behavior seems to be meant for overhead view games rather than platforming. I can only hope that in a later release pathfinding will be extended to platform games as well.

  • you mean like so

  • Just a quick note for anyone trying to run this demo using the r195 version of Construct 2 available on the front page. It seems that you need to use the r198 version to run it. I'd post the link to it but I'm not allowed to use URLs in posts yet

  • I know, you can put up the link just don't use the header

  • [quote:20wl1n0k]I know, you can put up the link just don't use the header

    Thanks for the tip

    Construct 2 r198 can be downloaded at

  • you mean like so

    Thank you for your example but this is still pathfinding being used in an overhead view rather than a side view platform game such as GameThirsty and myself are talking about. We are looking for a way to use the pathfinding behavior to cause a sprite to move along solid platforms and jump gaps to reach a goal. As far as I can tell, the current path finding is not useable for such a thing in platform games.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)