I'm writing a 2D tile based RTS. And I want to add a 'pseudo 3D' feature to it - bridges over the rivers.

I havent't start any coding yet, just trying to think how it fits the collision detection model. A boat passing under the bridge and a unit moving over the bridge will eventually occupy the same cell on the map. How to prement them from colliding?

Is there a common approach to solve such a problem? Or I need to implement a 3D world to do this?

  • \$\begingroup\$ well if you are doing a tile based system, you could add something like an "isOccupied" method for each time. Just have the bridge check below itself and above. \$\endgroup\$ Nov 16, 2012 at 23:50
  • 2
    \$\begingroup\$ if ground units don't interact with water units, you might handle separatly collisions for both sets of units. And maybe consider a boat at the harboor is a ground unit to allow interactions like the player/a npc entering the boat. \$\endgroup\$ Nov 17, 2012 at 14:10

2 Answers 2


You'll basically have to create a third dimension, though in the simplest case it can consist of just two values: "on ground/on bridge" and "on water/below bridge".

An inspiration can be found in the way Advanced Strategic Command does it: Units occupy a specific height level, can only move around on height levels fitting to their type unless there are specific features allowing them to do otherwise (for example runways for aircraft) and changing them usually costs movement points, with penalties on some height levels or others. A tile can be occupied by any number of units as long as each is on a different height level.

In case of ASC, the levels are:

  • space
  • high altitude (bombing)
  • medium altitude (interceptors)
  • ground attack altitude
  • ground (most ground units and hovercraft, even over water)
  • water
  • partially submerged (submarines)
  • submerged ("hidden" submarines)

You can add a simple attribute to each tile that specifies its level.

So for example:

tileA.layer = 0 // Will be at the bottom
tileB.layer = 1 // Will be above level 0, on top of it. 

// Add tiles to layered list
List<List<Tile>> tiles = new List<List<Tile>>();

// Draw 'em in the right order!
void Draw(List<List<Tile>> tiles) {
    foreach( var listOfTiles in tiles ) {
        foreach( var tile in listOfTiles ) {

Now you can sort your tiles depending on their layer values and draw them bottom -> top! This will make it look like you have a certain depth in your game. Most tile engines support this. Another cool thing you can add is transparency to your textures so you can see through to the bottom layer.

This can be done with water for example - imagine the water at lvl 1 and then the ocean floor at lvl 0. If the water texture is somewhat transparent, you will be able to see the ocean floor from above.

  • \$\begingroup\$ @aleguna No worries! It's just fun to help out. :) \$\endgroup\$
    – Zolomon
    Nov 16, 2012 at 20:59

You must log in to answer this question.

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