3
\$\begingroup\$

I want to create a 2D isometric game. Currently I'm looking and testing Phaser game engine with isometric plugin. Almost everything at the moment looks possible except few things. I will create a bridge/tunnel in my map so entities could go through tunnel and on the bridge. The simplest implementation of this simulation will be enough.

What kind of trickery I have to use to implement pathfinding algorithm in this situation? And is this event possible in 2D isometric games? What are your suggestions about this type of game overall and my problem?

Picture with bridge/tunnel for better understanding:

\$\endgroup\$
3
\$\begingroup\$

I disagree that you have to have a 3D map for this, and depending on how far along you are and how you implemented things, it might be a lot of work or bring other problems if you try to convert your tile or map system from 2D to 3D. On the other hand, it might be appropriate for your game and even help you with other things, but that's hard to say without knowing your game and your plans very well.

If you want to stay in 2D, you'd have to implement some special logic depending on tile type. You could make certain tiles only passable in certain directions (e.g. not letting you turn left or right at this bridge/tunnel tile, or having one-way tiles that only let you pass in one direction - for example for dropping "down", like you could in older Zelda games). Your pathfinding then has to follow these rules when expanding the set of possible moves from the current tile.

The trickiest thing about this is probably the rendering, because you'd want to have elements on the bridge stay visible and those below should appear to be under the bridge. One approach would be to compose the tile of two seperate sprites, one floor and one bridge sprite, so that you can draw the bridge sprite after an object that's below the bridge, but before an object on the bridge.

\$\endgroup\$
2
\$\begingroup\$

So you might be rendering in 2d, but effectively by doing this your game map is no longer 2d, it is in fact 3d. You could handle this by pathfinding in three dimensions. Assuming a 3x3 grid with a tunnel going north and a bridge going east, then you effectively have two stacked tiles at (1,1). So treat them as (1, 1, 0) and (1, 1, 1). In your pathfinding logic where you consider the connectivity of tiles, you can always return false for changes in the height axis, except at the ramps down to the tunnel or up to the bridge.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.