How do I use the pathfinding behavior in a platformer?

1 favourites
  • 4 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hi. As the title suggests, i'm trying to create an enemy that can pathfind to a preset location (determined by a sprite), but the behavior currently is pathing far above the ground, and as such the enemy is practically neutered and actually path to anywhere (as well as continuously jumping up and down while trying to align itself directly to the path before continuing) any adivce? i'd like to get it to be able to jump over gaps, do a bit of platforming, that's really about it.

  • Man I have sunk a couple of hours into this problem and I still have no idea where to even begin :D It's really not an easy problem depending on how complex you want it. I'd argue the build-in pathfinding behavior is not suited for this type of problem. I've personally never managed to solve it.

    The basic idea is building a nodetree with connections, then use A* to find a path through that tree. But as to how to have the enemy properly traverse along the path... no clue.

    Maybe now that I have a bit more clue about js I could try again but this is rough.

    For a much more basic implementation. A handful of raycasts can do the trick.

    -Move towards the target sprite (either left or right)

    -Shoot one ahead of the enemy, if it hits a wall -> jump

    -Shoot one down from the enemies feet, if it doesn't hit anything there's a pit -> jump.

    This is crude and will not work for anything that requires more complex pathing.

  • I tried generating a bunch of nodes, then having it walk towards the nearest node, then delete it, and then go through it again, but it only ever worked going in one direction, and i gave up on that after a little while.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Also, unrelated to what i called you here for, but the enemies currently act as one- if the state of one changes, they all change (despite my best efforts to prevent this). Please remind me how to keep their states separate (it is all done with instance variables, but i am stupid)

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