How can I make pathfinding work in 3D?

0 favourites
  • 2 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • How can I make pathfinding work in 3D?

    What if I want the enemy to be able to follow me both under and over the platform I'm standing on?

    Is making something like a Navigation Mesh even possible in Construct3?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The pathfinding behavior (or most all construct behaviors for that matter) only work for 2d. That means in 3d it works on the xy plane where z=0. The obstacle map for the pathfinding behavior relies on 2d collisions so we are limited by that too.

    Most you can do is vary the z of the objects as they move along the path.

    More complex could be to to transform the pathfinding to a different plane or wrap the plane onto a 3d surface. That would entail having the pathfinding done as normal and transforming the resulting position in some way. Main problem with that is visualizing it so you can design the maps.

    Things like tunnels, overhangs or multiple levels simply isn’t possible. Well other than just having a separate path per layer and having a manual transition between levels to switch. That does have its limitations on the kind of levels you can do and you’ll have to work around things like the pathfinding map being shared between behaviors as an optimization.

    Second option is to roll an event based solution. For simplicity we could just have a list of nodes and a list of connections between the nodes. Nav meshes would be more complex since they also define walkable areas, not just lines.

    Anyways building those lists is tedious in construct. Making a way to mostly automate it would have to be done on a game by game basis. Probably an in game editor would be the easiest way to define them, or somehow exporting a rough 3d approximation of the 3d level to a 3d format that you can load into blender or something and create the mesh on top and then load back into your game. So overall there is some tooling you’d need to do to make defining the mesh doable. Simplest would be to a grid based array of nodes since that’s easy to generate. But you may want to modify it more somehow.

    The second part is the actual pathfinding over the mesh. An algorithm such as Astar isn’t too complex and works well with lists of nodes and connections. Most implementations you can find just do something grid based since it’s simpler.

    Anyways after that you’d either get no path or a list of nodes to move to the goal.

    The final part is moving along the path. The move to behavior comes to mind or you could do something else.

    For something like in your screen shot you could get away with something much simpler than all that. Just move enemies toward the player and wall slide around walls. If the player is on a higher platform move the enemy to the closest ramp to move up. Then if you have any places the enemy gets stuck you could you just detect if the enemies are there and move them away.

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