Sign in to follow this  
lukadev0

Best way to do collision detection for a 2D Platformer

Recommended Posts

lukadev0    122
Hi everybody..
I have a question:What's the best method to perform collision detection & response in a 2D platformer?
There's AABB,Polygon intersection,ray casting (used in sonic),the collision points(that surround the player),..
when I say best I mean the approach that gives you the most possibilities..I know this is very game dependant,let's say that I want to make a braid-like style of game, where platform physics just feel natural (sonic too) and where the platforming isn't the core gameplay!

Share this post


Link to post
Share on other sites
LJ_1102    1233

I recently stumbled across this gem that explains collision techniques and physics like simulation.

There are a lot of cool interactive flash examples to help understanding the concepts.

Maybe this helps you.

Share this post


Link to post
Share on other sites
lukadev0    122

Ok,Thank you..This helps!

But what I'm asking here is a comparison between the different techniques..

For example the ray casting technique gives you more awarness of what's happening around the player than the AABB technique.

What's the best method to implement 2d platformer games collision detection & response?

Share this post


Link to post
Share on other sites
LJ_1102    1233

There isnt the one and only technique to do "most aware" collision.

It highly depends on what is needed. If you need your character to know that hes falling into oblivion you'll have a ray beneath him.

Also you will propably need a bounding box for the actual/current collision with the level etc.

 

So the best method is to have a set of bounding primitives that you can use in the appropriate cases.

Share this post


Link to post
Share on other sites
Satharis    2444

Generally the rule is "simpler is better" more complex methods of collision detection than simple AABB type ones tend to either cost development time or CPU time(or both!) Which method you use really goes down to the specifics of your game. If you look at a game like original pong(square boxes bouncing against other square boxes at a relatively sane speed) collision detection can be very simple. If you're doing a complex platformer game with spike balls bouncing off trampolines and flying into breakable walls then you might need to adjust to something more heavy duty.

Share this post


Link to post
Share on other sites
Khatharr    8812

The Metanet article really is one of the best primers on collision detection you're likely to come across. Even if you don't understand some of the more advanced techniques they discuss it will give you an overview that helps to shape your thinking about collision.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this