YesNoOk
avatar

Tutorial Part 2 - Collision boxes (Read 27750 times)

Started by JustNoPoint, November 03, 2015, 09:18:02 pm
Share this topic:
Tutorial Part 2 - Collision boxes
#1  November 03, 2015, 09:18:02 pm
  • ******
    • www.justnopoint.com/

How Do I...? A M.U.G.E.N primer

Tutorial Part 2 - Collision boxes

M.U.G.E.N, Elecbyte (c)1999-2009
Updated 17 September 2009


Tutorial 1 | 2 | 3 | 4

Introduction

In this part, we will talk about how to define collision boxes for the animations in your character's .air file. The documentation for .air files is in air.html. It's a good idea to read it before proceeding with this tutorial.


1. About Collision Boxes

Once you have put together an animation for the character, you can use AirEditor to define collision boxes. There are two kinds of collision boxes:

  • Clsn1 - Attack box (red in color)
  • Clsn2 - Hit box (blue in color)
Simply put, if one of Player 1's attack boxes overlaps any one of Player 2's hit boxes, then it means Player 1 has hit Player 2.


2. Using AirEditor

AirEditor is a developer tool, and can be found in the old_tools/ directory of your M.U.G.E.N installation. The instructions for using AirEditor are in airedit.txt. When you are ready, run the airedit executable.

Go to File -> Open and choose the sff file you want to load, followed by the accompanying air file. You will now see your character on the screen:

AirEditor screen

Let's explain what you see on the screen.

  • The big window that you see your character displayed in is called the Display window. The title area shows the current animation action you are looking at, as well as the sprite number of the sprite shown.
  • The Info window at the upper-left shows:
    • X,Y coordinates of the cursor, which is displayed as a crosshair in the display window
    • X,Y position of the axis of the sprite, relative to the upper-left corner of the sprite. This is the number you entered in the player-sff.def file used to generate the SFF
    • Coordinates of the two opposing corners of the box you create when you drag the cursor on the display window
  • The Navigation window:
    • Current action being displayed. You can scroll through the animation actions in your .air file by pressing the arrow buttons on either side, or you can enter it manually by clicking on the middle button
    • Current element of the action that is being shown. You can scroll through the available elements, or manually enter it, just like the action
    • Click "Play Anim" to preview the animation
  • The Collision boxes window:
    • There are buttons here to let you set the bounding boxes for the current animation element
  • The Options window:
    • A toggle button to enable/disable display of the Clsn1 (attack) box
    • A toggle button to enable/disable display of the Clsn2 (hit) box
    • A toggle button to enable/disable display of the sprite's axis
  • The wide grey box at the very top of the screen beside the menu is the Status bar, which shows you some information, such as your last menu action.
  • At the bottom of the screen you see a row of Save boxes. Each of these represents a slot that you can save a box into. The clear button erases them all.

To define a collision box, simply drag the mouse cursor over the region you want to create a box at. This will be displayed as a bright green box. Click without dragging to make the green box go away. Let's start by defining boxes for KFM's standing frame. First, we'll drag a box to represent his body.

Boxes1 Boxes2

Click on the Save1 button at the bottom of the screen to save that box to memory. Now drag a second box for the head and click on Save2 to save that. Notice how the saved boxes appear in a darker color. If you want to go back and correct one of the saved boxes, simply drag a new green box.

Next, you assign the set of boxes to the current animation element. Click on the corresponding "Set" box in the Collision boxes menu. Repeat the procedure for all the elements in the animation action.

When you are done with your changes, remember to save your .air file. Click on the File menu and choose Save.


3. General Tips

  • You can quickly load your character by specifying the .sff and the .air filenames at the prompt. For example,
    airedit chars/kfm/kfm.sff chars/kfm/kfm.air
  • If you have a lot of frames using the same set of boxes, you can scroll through each element, saving the boxes to the .air file without clearing the boxes each time. Alternatively, you can set the collision box as "Default" to define a default set of boxes for each frame within an action. Click on the "Options" Read air.html for more information on default collision boxes.
  • In common cases, try to keep Clsn2 boxes within your Clsn1 boxes. The reason for this is so that it becomes possible to trade hits between players. If you have a Clsn1 box without a Clsn2 box in it, then setting priorities on attacks becomes meaningless, as the attacks would have infinite priority that way.
  • Don't be too detailed with your collision boxes. The point is not to make a pixel-accurate representation of the character, but to make one that is game-friendly. For example, boxes for your character on the ground should have Clsn2 boxes that span the space between both legs. In this case, too much detail is actually undesirable.

    Here is a picture of a one that is too detailed. You want to avoid this.
    Too much detail

    This next one has a better set. Not only does it take less effort to create, but it better approximates the movement of the character over time. Also, there is less chance that a Clsn1 box from an attack would slip through a gap.
    Just right



Tutorial 1 | 2 | 3 | 4

Next is Tutorial Part 3


ADDITIONAL NOTES:
The current recommended program to make MUGEN content is Fighter Factory.
You can find it here
Last Edit: November 03, 2015, 09:51:38 pm by Just No Point
Re: Tutorial Part 2 - Collision boxes
#2  November 04, 2015, 08:57:30 pm
  • ******
  • [E]
    • Mexico
this is the one that needs notes because of infinite priority; in real games, infinite priority exists and works well but/adn a magic priority number does not exist.
Re: Tutorial Part 2 - Collision boxes
#3  November 05, 2015, 05:47:54 am
  • ******
  • Legendary XIII
  • I am the eye of the storm to come!
    • New Zealand
    • network.mugenguild.com/cyanide/
I see little purpose to this. It talks about air editor which NOBODY really uses. So it's not describing anything that's going to make sense to most new people.

The very last paragraph is useful. The rest should really be consigned to history at this point. Fighter Factory's ability to make clsn boxes is so far superior to this, posting a tutorial on it is silly.

Or you could start the whole thing with "Deprecated" and you'd be all right.


In M.U.G.E.N there is no magic button

They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance.
Re: Tutorial Part 2 - Collision boxes
#4  November 06, 2015, 07:18:41 am
  • ******
  • Hedgehog Whisperer
  • Red Bull addict
    • Spain
    • xgargoyle.mgbr.net
perhaps it may be wiser to rewrite the first post and focus on the clsn theory basics and links to the different options we currently have to display hitboxes in commercial games and how to extract them (LUA scripts, debug bios, secret menus, specific custom tools...)
XGargoyle: Battle posing since 1979
http://xgargoyle.mgbr.net
http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
http://paypal.me/XGargoyle  <-- Donations welcome!
Re: Tutorial Part 2 - Collision boxes
#5  November 06, 2015, 11:09:27 am
  • ******
    • www.justnopoint.com/
Yeah I think I'll "remake" this with that info and using FF instead. Just put a disclaimer that this current tutorial is still here for completions sake.


A discussion stemmed from this post due to the image of CLSN shown below is being split to this thread.
Last Edit: November 17, 2015, 04:38:41 am by Just No Point
Re: Width (SCTRL)
#6  November 15, 2015, 09:08:37 pm
  • ******
  • Loyal to the Game
    • USA
    • http://jesuszilla.trinitymugen.net/
Please update your post with better CLSNs for Ryu because I really don't think people should be taught that that type of design is OK because that largely causes issues like the one you're describing.
Re: Re: Width (SCTRL)
#7  November 15, 2015, 09:54:07 pm
  • ******
    • www.justnopoint.com/
I considered saying something about that too but didn't know if I should turn the thread into a proper CLSN thread.

Odb, if this is from your Ryu please allow me and to update your CLSNs :p
Re: Re: Width (SCTRL)
#8  November 16, 2015, 10:28:16 pm
  • *****
  • Shame on you!
    • USA
lol my Ryu's never had problems with his/my clsns. Not once.
I actually edited the clsn boxes so you could see the lines a little better for these images.
It's hard to see the width line when the blue box is lined up on top of it. I was even thinking about dropping back to 480 to make the line a little clearer.
vVv Ryuko718 Updated 10/31/22 vVv
Re: Re: Width (SCTRL)
#9  November 16, 2015, 10:43:41 pm
  • ******
    • www.justnopoint.com/
I'm sure it doesn't hurt your push any it's just "bad" CLSN making that probably shouldn't be shown as good examples in the Class. A stance should only have 2 or 3 CLSN boxes at most. Even the outdated character tut from the docs shows this is bad :P
Re: Re: Width (SCTRL)
#10  November 16, 2015, 11:54:48 pm
  • *****
  • Shame on you!
    • USA
Why? Why cant mugen handle more than 3 hitboxes?
vVv Ryuko718 Updated 10/31/22 vVv
Re: Re: Width (SCTRL)
#11  November 17, 2015, 12:15:47 am
  • ******
    • www.justnopoint.com/
  • Don't be too detailed with your collision boxes. The point is not to make a pixel-accurate representation of the character, but to make one that is game-friendly. For example, boxes for your character on the ground should have Clsn2 boxes that span the space between both legs. In this case, too much detail is actually undesirable.

    Here is a picture of a one that is too detailed. You want to avoid this.


    This next one has a better set. Not only does it take less effort to create, but it better approximates the movement of the character over time. Also, there is less chance that a Clsn1 box from an attack would slip through a gap.



    Not to mention that more CLSN data requires more processing power. It's not that MUGEN can't handle them it's just that they are deemed improper by fighting game standards for the most part.

    I'm not saying you HAVE to redo your CLSN boxes on your Ryu. I mean you can make them however you want TBH.

    But I think proper CLSN structure should be advocated in this board. That doesn't mean they have to be pixel accurate. Just that they shouldn't go more than 3 in most cases.
  • Re: Re: Width (SCTRL)
    #12  November 17, 2015, 12:33:04 am
    • ******
    • [E]
      • Mexico
    Why? Why cant mugen handle more than 3 hitboxes?

    60fps are very undetailed to represent proper real/fluid physics (even more so because fighting games animate even slower character frame wise); racing games go at 300 fps some even even 1khz for some things.
     since running a fighting game at that speed might be difficult (I am programming at 120 hz and certain thigns change a lot); fighting games like most other games for which this is a problem seetle for the next best thing, emulate fluid motion using clsns. if you have your legs apart and someone kicks the space between your legs from the front, even the tip of his leg lands  in between your legs, where there should be no contact in that position, for the front leg to get there it has to pass through yoru front leg, which should register a hit; one way to prevent the bug to happen is to extend the attacking leg's clsn so it cover the area which the feet travels; another is to put clsn in between both legs, since there's no way something will hti that place without hitting the front leg.
    Re: Width (SCTRL)
    #13  November 17, 2015, 04:00:27 pm
    • ******
    • Hedgehog Whisperer
    • Red Bull addict
      • Spain
      • xgargoyle.mgbr.net
    Having a Capcom character with wrong clsn is a big failure nowadays, something easily corrected with all the LUA hitbox viewer available out there
    XGargoyle: Battle posing since 1979
    http://xgargoyle.mgbr.net
    http://www.pandorabots.com/pandora/talk?botid=e71c0d43fe35093a  <-- Please click that link
    http://paypal.me/XGargoyle  <-- Donations welcome!
    Re: Tutorial Part 2 - Collision boxes
    #14  November 17, 2015, 04:09:09 pm
    • ******
      • www.justnopoint.com/
    I went ahead and moved your post here since the CLSN discussion makes more sense in the Collision boxes Tutorial thread.

    And while I totally agree that it's super easy to get accurate hit boxes now and people should be motivated to do so. It does require extra work to data mine them even if it's not hard.

    If a person doesn't feel like going through the trouble of doing that they shouldn't have to do so. But I do HIGHLY recommend them to study just a bit the rules of CLSN making by looking at examples and not make them over detailed like here at the very least.
    Re: Tutorial Part 2 - Collision boxes
    #15  November 17, 2015, 07:03:13 pm
    • *****
    • Shame on you!
      • USA
    I've only ever had slowdown because of Dragonclaw's ultras back on old winmugen/crappy pc days. Now with 1.0, it's hi-rez stages and a ton of explods. Not once has any amount of clsn boxes slowed mugen.
    Has anyone ever experienced slowdown because of clsn boxes? This is an honest question.

    My view of hitboxes and everything else that goes into a character is, 99% of the time a character is unique. We dont fight rectangles.
    I dont believe being able to attack Air, Hair, Fingers, or Toes, should be possible. If I could make a "green" box so you could "throw hair" I'd do that in a heart beat. Should you be able to punch hair and hurt the player?

    As for the hole in the legs. It'd be VERY hard to have an attack miss. A very specific chain of events would have to take place for KFM's width and attack to allow something between his legs. Well, this IS mugen. It could actually happen. there's 99,000 characters out there. But here's the thing; Imagine it happening in the battle. It's a one off; Unique. It may never happen again, but when it does, it'll be crazy accurate. Why is this bad?

    But lets go back to the big square representing what happens in the lack of animation vs movement. First, with the physics of the attack if I remember correctly, KFM slides forward a bit using only that frame of animation. Mugen wont forget to take into account the hitboxes until KFM stops moving... oh wait it never does. So the movement and filling in the gaps are actually done in game by mugen applying the movement. When KFM becomes stationary, Why should P2 be able to attack air??

    I dont see the benefit of fewer clsn boxes. Capcom hit boxes, SNK, MK, all of them are great for their own respective games. They work in the games because they dont fight Pop-Eye. They fight each other with standard boxes FOR THAT GAME. But they dont equal out when fighting vs other games.  I view the possibilities in mugen, the potential of mugen, to exceed any other fighter out there. Why dumb down?

    This is what you get for source.

    Cant punch Blanka in the face, The attack box for Dhalsim doesnt follow the path of the kick, Blanka can kick all that white, or if he was on the ground, do his long punch and hit the air under the leg. If Dhalshim was slow on the attack Blanka could also attack air on the backside.
    So why is Blanka's face unhitable? because he's jumping forward, or is he jumping backward in this frame? Can you tell? Should it matter? At this specific point in the action, you should be able to attack his head. BUT! Less clsn boxes are better? Source is perfect??

    This is my take on that instance

    One extra box for Blanka. How terrible is it guys?
    vVv Ryuko718 Updated 10/31/22 vVv
    Re: Tutorial Part 2 - Collision boxes
    #16  November 17, 2015, 07:12:33 pm
    • ***
    • MAX 330 MEGA PRO-GEAR SPEC
      • UK
    What's the point of a smack on the toes being enough to knock Blanka out of the air like it would.
    That box is also exactly the same during his entire jump animation covering slightly past his feet on the fully contracted frame, and helps serve the purpose of a jump to dodge certain attacks and projectiles. For whatever reason most air hurtboxes in SFA appear to be placed so the character axis is straight in the middle, regardless of what the sprite shows or characters where their pushbox isn't identcal.

    It's easier and quicker to do a couple of simple boxes to cover the general center of mass and leads to less weird situations and inconsistencies between characters of the same size, or animations in the same character where boxes are placed differently.

    Also the point of Sim's gigundo boxes is to offer a drawback to a character whos gimmick is free long range attachs with one button, in this case it rewards the Blanka that jumps over his foot allowing him ample space to hit his stretched out leg. Granted, the Marvel engine supports a fourth hurtbox to be used in attacks but that still covers only slightly less vertical space than it does in SFA for Dhalsim.

    Alpha 3 does have tiny red boxes, I won't contest that, but the same move in Alpha 2 has the same blue box but a larger red one that reaches slightly further and higher on the screen than the blue does. It doesn't let his thighs act as a deadly weapon though.
    Last Edit: November 17, 2015, 07:34:25 pm by The 100 Mega Shock!
    Re: Tutorial Part 2 - Collision boxes
    #17  November 17, 2015, 08:52:30 pm
    • *****
    • Shame on you!
      • USA
    If Blanka was moving forward and his feet are attacked, his trajectory would definitely be more affected than hitting center mass. It'd add a spin affecting near every positioning of his body. Back, Neutral, it'd add a spin to his body. Should Zangief not be able to grab his head, right shoulder, right forearm and hand, Right shin, and feet?? 7 viable points of attack.

    I agree that Dhalsim's entire thigh shouldnt be able to attack. What you're not seeing in my image is how my red boxes follow the movement. Depending on the attack I'll duplicate the same frame but bring the attack towards the end of the limb. Dhalsim's foot actually follows on the path of the thigh on the tangent. My red boxes display the movement when there is none.
    I believe in a fight, when an attacker punches, it's easier for you to get hit than attack the arm. The blue boxes should be a lot tighter than the red. You can kind of see that in Dhalsim. 

    As you just mentioned the same character, presumably using the exact same sprites, having different clsn boxes in different games, Which idea of the boxes is the best? Is it personal choice? Or are they based around that particular game's mechanics? Because this is Mugen, and should be using Mugen hit boxes. Because 1 company isnt creating the characters, I feel the boxes should be as character specific as possible.

    Just because a character is the same basic size as another character shouldnt mean they get attacked the exact same way. Each character is different because they're different. Dhalsim gets to have long fast legs because he walks slow as heck. Zangief gets to take off massive damage with his throws because it's difficult to get in close.

    Having consistent hitboxes for each identical frame is up to the creator. Up until recently I'd do all of my hitboxes by hand. Now I use find/replace to make sure they're exactly the same. But, like Dhaslim's SFK, I use different boxes on purpose. If you really want to get a look at how I want my hitboxes, my Mia718 is probably the best. Most, if not all, of her basics have the trailing off effect. Where the attack focus fades toward the end of the limb. I even have some where the same frame is used without the attack boxes to make counters a little easier.

    No one's given an example where Ryu in statedef 0 with his standing hitboxes having the opening between the legs would cause a problem. Because there isnt. But being able to punch the air between his arm and calf is very much needed?
    vVv Ryuko718 Updated 10/31/22 vVv
    Re: Tutorial Part 2 - Collision boxes
    #18  November 17, 2015, 09:25:58 pm
    • ******
      • www.justnopoint.com/
    I still don't think you understand the full concept of how hit boxes are supposed to function. They don't just adhere to the sprite itself. Heck some hit boxes place CLSN1 under or above the limb of a sprite.

    You're applying real world physics to each frame and that's not the method in which it should be taught. If you personally feel like making your hit boxes like this no one can stop you. But it's important to note why it's perceived as wrong by functionality and community standard. And not just MUGEN community standards. This is Fighting Game Community standards and a FGC would find these CLSN very amateurish.

    The Blanka in your example isn't horrible. It's just a bigger hit area. Dhalsim's kick on the other hand is very over powered there. It can hit near and far, it can hit low and high. It can barely be punished at all because the CLSN2 are hidden so well within all that CLSN1

    There is no "right" and "wrong" per say for the size of boxes. Heck, there isn't even a real rule against using several boxes like you're doing. But there is an agreed upon rule of thumb to how these things are done in all major fighting games. And as such that should be our base for teaching. The base is always the standard and then you deviate from that if you choose.

    We can go back and forth why you think this CLSN should be that and vice versa instead of the norm. But in the end the norm should be what's taught. Because it's what evolved the best fighters to be the best. And it requires a lot less work than adding so many CLSN boxes.
    Re: Tutorial Part 2 - Collision boxes
    #19  November 17, 2015, 11:41:05 pm
    • *****
    • Shame on you!
      • USA
    The amount of hitboxes in Dhalsim, and Blanka, and Ryu, and Mai COMBINED dont match up to what's inside Samus. The amount of frames each with 6 or 7 or more blue hitboxes makes the amount of work in 1 character trivial. Roberto is getting the same treatment Samus got. 2 standing attacks from Roberto is the same amount of frames of ALL of MY Ryu's basics. To date, I dont think there's a Ryu with more basic attacks.
    Old school characters arent that much work.

    Punishing an attack free and clear should only happen from a special. If Ryu throws a fireball, he wont get hit. If Ryu tries to tag the leg by punching or kicking, what would happen if two people kick each other's leg? The both get hurt. If you can time the attack when Dhalsim's retracting his leg, yeah it's free and clear. Just like in practice that's a lot harder said than done.

    Blanka's hit area should be bigger because he's a bigger character.

    I'm using images I've uploaded when I had a discussion about hitspark placement and how I wanted to make a better system... but this should hopefully work as an example.

    I've had a similar conversation in my Ermac thread. and Jesuszilla posted


    Evil Ken's punch lands completely clean because his blue box doesnt extend into the hand, breaking tip #3. I know it's silly to equate to real life, but the kick would win every time.  (why the hitspark is on the chest I'll never know)
    Obviously the Guile example is pretty old, but let's go with it. The only reason I can imagine for the attack box to be higher is to counter air attacks. Someone standing's getting hit, someone crouching's getting hit. There isnt a character in the game who's shorter. EVEN if they were shorter, that's even MORE reason to lower the red bar. Maybe Dhalsim's slide in, but if Capcom made his boxes tighter the two wouldnt connect.
    In my opinion the red bar should match the arm, along with a blue bar, so that you as the player have to time the attack better. And if it is to counter air attacks? Oh well. Learn your character half a second longer til button press or Crouching LP wont counter Air kicks... move on.
    Someone please tell me what the heck the reason is for Guile's CLP boxes. Honestly, if you can explain to me why they're like that I might actually see the reasoning. Right now, I could like probably 4 or 5 more reasons it should be like I suggest.
    Basically, it's a way of cheating instead of making the character who it IS.
    Guile also breaks tip #3

    BTW, This is supposed to be the guide. Up until now I've never seen a full discussion or set of rules for how high your crouching light punch box should be off the ground. I've only seen guides on how to rip source or heard people complain it's not source. There's no Mugen hitbox discussion that I've seen til this thread. 
    I doubt it's even possible to try and combine or put together basic thoughts on clsn boxes that arent centered around 1 game.  Even if you could, that game wouldnt be Mugen.
    No one will answer why you should be able to punch air.
    vVv Ryuko718 Updated 10/31/22 vVv
    Re: Tutorial Part 2 - Collision boxes
    #20  November 18, 2015, 02:47:32 am
    • ******
    • Loyal to the Game
      • USA
      • http://jesuszilla.trinitymugen.net/
    Holy shit your posts are giving me a headache. I can't even be bothered to read them in their entirety with your flawed logic. You don't have to, and shouldn't, make everything literal. I learned that a long time ago.

    Everything is designed a certain way for a clearly defined functional reason. Priority in traditional fighters is determined by hitbox size and placement. Doing it the way you have it pretty much leaves everything up to the character with the fastest speed and lowest height because you're not thinking about the design other than "it must completely cover the region!"


    Take this for instance. I designed it so that the attack box would go with the motion while still leaving him completely vulnerable low so that it will beat out most crouching punches but still leave him open to most crouching kicks.


    Now here's my favorite. The hitboxes are not placed right where his legs are. Do you want to know why? Because he wouldn't be able to fucking hit most opponents if I didn't do this! He would be too high off the ground to even hit Ryu unless I put him at an unreasonably low height that would cause him to land faster and not look as good in motion.