Wednesday, August 15, 2018

3d - Boat passing under a bridge in a 2D tile based RTS


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?



Answer



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)


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...