Jump to content

Collision detection in 3/4 perspective


imacomputertoo
 Share

Recommended Posts

Does anyone know how to do collision detection for games with a 3/4 (or angled) perspective. Examples are Teenage Mutant Ninja Turtles on the NES or Streets of Rage on Sega. In those games the player can walk from below up to a wall until their feet contact the wall. So only the bottom of their sprite collides with walls. But their whole sprite collides with bullets and attacks. I've been trying to do this forever in Phaser and I can't figure it out. Has anyone tried this before? Are their any examples of this in phaser?

Link to comment
Share on other sites

It also depends on if you are going to have obstacles above the ground that can impede the players or enemy sprites. For example, in the Streets of Rage image above, if you planned to have a wall that started a couple of feet off the ground that needed to make players crawl under it, or in some way stop them, it gets more complex. 

But if you don't need that, you can get SoR-style collision detection by actually using two collision boxes. The first is the movement collision box, and this is mostly around the player's feet. This helps with the design a bit, since you can block off entire upper walls as being a collision zone, giving you less to think about when you need to have a path going up into the top wall or need to give a path down into the bottom wall. Centering the movement (or "environmental") collision box at the sprites' feet allows you to set up stage collision boxes to be nearly the same as the walls and obstacles as they appear in your stage art. 

Then you can put another collision box around the full sprite to register collision detection for hits, etc. 

Of course, more collision boxes = more collision calculations. And with certain types of games this can become a problem. In a Streets of Rage type game it would not be a huge issue since you typically only have 3 or 4 characters on the screen at once. But if you needed to have bullets flying all around or dozens of enemies on screen in complex collision-based stages, this is probably not the way to go. In that kind of case I would suggest trying to find a good way to use a single collision box per character. 

Link to comment
Share on other sites

  • 3 weeks later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...