imacomputertoo 0 Report post Posted September 1, 2017 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? Quote Share this post Link to post Share on other sites
samid737 118 Report post Posted September 1, 2017 I think if you add the top wall above the ground it will work: you can add invisible sprites with arcade physics and use setSize for example to change the width/height of the collision boxes. 1 imacomputertoo reacted to this Quote Share this post Link to post Share on other sites
Jackolantern 13 Report post Posted September 2, 2017 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. 1 imacomputertoo reacted to this Quote Share this post Link to post Share on other sites
imacomputertoo 0 Report post Posted September 22, 2017 Thank you so much for the helpful response! I had thought of the two collision boxes thing, but I don't know how to do that in Phaser. Any suggestions? Quote Share this post Link to post Share on other sites