Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

tehJaquio

2D fighting game collition

This topic is 5386 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

Hey, i want to code a 2D fighting game engine, im just wondering how do games like Capcom SF series or SNK series do collition detection, any ideas or links to white papers, thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
I don''t know specifically, but I would assume that the either do some sort of per pixel collision check, based on the animation masks... or they have a bound rectangle defined around "collision regions" ie arms, legs, head... and simply check if an attacking region of one intersects a non attacking, or defending region of the other. Just an idea, I don''t actually know :S.

Share this post


Link to post
Share on other sites
The method a lot of 2d fighting games use is collision boxes.

You have a collision box in the area a fighter can be hit. When the figher moves, ducks, etc, the box is moved/adjusted to again be where the figher is at.

If the two boxes try to overlap each other the fighters are walking into each other and shouldn''t be allowed to move further.

If the opponents attack (a collision box/circle is used for this as well) tries to overlap with the collision box, the attack has hit the fighter and appropriate actions for damage should be taken.

It isn''t ''pixel-perfect'' but if done right it''s easily ''good enough''.

Share this post


Link to post
Share on other sites
i was also thinking that it might work well to simple logically divide the stage in small squares (2d array) and make each animation fill the positions it fills on the array, each frame, so that collition can be logically check againt the array, rather than the character itself. (just another idea that recently ocurred to me) Ej.

in a stage piece this big:

00000000000000
00000000000000
00000000000000
00000000000000
00000000000000
00000000000000
00000000000000

a character punching animation might look like this:

00000110000000
00000111000000
00011111111110
00001111000000
00000111000000
00000111000000
00000111100000 (can you see the character, heh)

Share this post


Link to post
Share on other sites
per-pixel collision will be slow as hell if you check every pixel of every object (even with just two big characters) every frame. but, you can use the bounding boxes mentioned earlier, and then if that results in a collision you can run the per-pixel on the overlapping part of the two boxes, which will be much faster than doing the whole thing each time.

Share this post


Link to post
Share on other sites
quote:
Original post by krez
per-pixel collision will be slow as hell if you check every pixel of every object (even with just two big characters) every frame. but, you can use the bounding boxes mentioned earlier, and then if that results in a collision you can run the per-pixel on the overlapping part of the two boxes, which will be much faster than doing the whole thing each time.


If you do this the trick would be making the box as small as possible while still having the entire character contained...

The real question is whether or not pixel perfect is really worth it. If you want to see what the commercial games did, one of the MK games had a ''cheat'' that lets you see... (hint: it draws the boxes on the screen )

Share this post


Link to post
Share on other sites
If you look at Mugen they have a tool for creating hit boxes over sprites. Multiple hit boxes (or circles) would be the way to go. You could do per pixel collision pretty quickly, and if you need this kind of accuracy you could do it at a decent speed, but I think it''s overkill.

Share this post


Link to post
Share on other sites
does developer defined bounding boxes need to be generated for every frame of animation? (if so i guess a nice way to do it, is to have each frame of animation have a pointer to a list of its boxes, since most animations will share boxes anyway)

another thing, have any of you tried coding a 2d fighter before?

Share this post


Link to post
Share on other sites
That''s exactly what I''ve done. I have a "hitrect" for every frame where an attack is present. So, for collisions, I check the attackers hit rect and see where it overlaps the defender''s main rect (entire area). Then, using the corresponding rectangle, I do some more checks, some of it is pixel perfect, but there are some optimizations. Bounding rectangles is the way to go.

-----------------------------
kevin@mayday-anime.com
http://www.mayday-anime.com

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!