Jump to content
  • Advertisement
Sign in to follow this  

Super Mario Style Game - Tile Collision Problems

This topic is 2861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to write a platform game in a similar style to Super Mario. I'm currently having an issue with regards to my collision detection method used in my game.

Currently, I am employing an approach similar to the one described here :
N Tutorial A

Essentially, every frame, I check my character's bounding box to see if he intersects with any tile in the game world. If he does so, I proceed to calculate the projection vector of the overlap, IE how much he is intersecting a tile by. I then push him out in the relevant direction to prevent him from overlapping any tile.

Unfortunately, I seem to experience problems when my character is moving horizontally. At the moment, I apply a Y velocity to my character at all times. This is so that if he walks off a platform, he begins to fall.

The problem I am experiencing is that when I check all tiles for intersection, I am returned a tile below my character (IE the tile he is walking on). This is because of the vertical velocity being applied to my character via gravity. However, I only ever return one tile so this could well be my problem... perhaps I need to iterate through all the tiles my character is colliding with, and only process the tile with which I am colliding with the most (IE have intersected the most)?

I can think of a number of other solutions to the problem, but all of the ideas I've come up with don't seem to work.

Any help would be most appreciated!

[Edited by - the_golden_gunman on July 20, 2010 12:09:24 PM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:

The problem I am experiencing is that when I check all tiles for intersection, I am returned a tile below my character (IE the tile he is walking on). This is because of the vertical velocity being applied to my character via gravity.

So check for left/right collisions *before* the vertical velocity is applied.

-----
BTW, the approach I use is to turn gravity on only when there is nothing below the player, that is, when there is no collision at (player.x, player.y+1). That way there's no pulling force while the player is standing on something, and it is much easier to check for left/right movement as the player is not actually colliding with the block below.

Take a look at the Game Maker platformer tutorial (yes, game maker...). As much as people seem to hate it, there is stuff to be learned from those tutorials and it's shown in such a simple way that it's easy to translate to whatever language/library you're working in.

Share this post


Link to post
Share on other sites
Quote:
perhaps I need to iterate through all the tiles my character is colliding with, and only process the tile with which I am colliding with the most (IE have intersected the most)?

Is there a particular reason you want to restrict the collision detection and response to a single collision?

As outlined in the N tutorial you reference, it might work better for you if you
Quote:
(2) determine collision results for each pair identified in step (1) (narrow phase).

In the case you mention, the player has a tile both in a horizontal direction and a vertical direction, process both collisions.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!