Skip to main content
GameDev.net gamedev.net
🔒 Locked

Best way to do collision detection for a 2D Platformer

Started by lukadev0 Apr 20, 2013 at 5:00 PM 5 replies 5.4k views
Original Post
lukadev0
lukadev0
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!
LJ_1102
LJ_1102

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.

Jan F. Scheurer - CEO @ Xe-Development Sign Up fo
lukadev0
lukadev0

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?

LJ_1102
LJ_1102

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.

Jan F. Scheurer - CEO @ Xe-Development Sign Up fo
lukadev0
lukadev0

OK
Thak you LJ_1102,That was enlightning in some way
thanks a lot!

Satharis
Satharis

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.

Khatharr
Khatharr

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.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.