This is the cornerstone of performing combos in a fighting game. Hit Stun is how long, in frames, that a character is stunned after being hit. Finally, the ignore and ignoreList variables will be used to ensure we don't hit a character too many times. hitStun determines how long the character we hit is put into hit stun. xHit and yHit are our knockback variables. The life variable will be used to determine how many frames the hitbox will exist and remain active. However unlike a hurtbox, a hitbox doesn't exist at all times. Like with our hurtbox, we need to set an owner and offset. Open the create event and add the following code.Ĭopy code Copied to clipboard. Add the create, step, end step, and destroy events to this object. Then create the oHitbox object and assign the sprHitbox sprite. Create a one-pixel sprite named sprHitbox and color it red. Just like the hurtbox, we need to create a sprite and an object. The hitbox is what actually checks for collisions and determines what to do after a collision is detected. The setup required for a hitbox is pretty similar to that of the hurtbox, but it has a bit more going on. Now that we have our hurtbox, we need to hit it. It is a lot harder to hit something that is 2x2 pixels than it is 50x50 pixels. When play-balancing your game, there is really only one rule to consider for hurtboxes – The smaller the hurtbox, the better it is. Now you can see your hurtbox following the player around in the game. In this case, that is our oPlayer object. When using other in this context, it is referring back to the original object this code is running from. Since we are using with we can also use other. So when we say with(hurtbox) we are updating the x and y position from that particular oHurtbox object that we have stored in our hurtbox variable. When you use with followed by an object name (or specific object ID) the code following runs as if that object were running it. Using with and other may be a new concept, so let me explain. This little chunk of code makes sure the hurtbox is following our player around. Add the create event, and add the following code. Create a new object, name it oHurtbox, and assign the sprHurtbox sprite to it. Now that you have your sprite, let's create the object. The alternative would be to create a custom-sized hurtbox sprite for every game object that might need one, which would be tedious and wasteful. We only need a single pixel because we are going to scale it to whatever size we need whenever we instantiate a hurtbox. Create a new sprite, name it sprHurtbox, make it just a single pixel, and color it green. If Makoto were to touch someone else's hurtbox with her hitbox, the other player would be "hit."įirst, we need a sprite for our hurtbox. The red rectangle is the hitbox of the attack, while the green rectangle is the hurtbox. This is an upward-angled punch used as an anti-air attack, hitting an opponent that is jumping at you. Here we see Makoto performing one of her special moves, Fukiage. See the example below from Ultra Street Fighter IV. In my opinion, fighting games offer the clearest examples of hitboxes and hurtboxes. I am going to be using fighting games as the main example for this entry. Whenever the two collide, we consider the attack to have "landed" and we apply its effect on the target. A hurtbox is usually associated with a character (or any other "hittable" object in your game). A hitbox is usually associated with some form of attack, and describes where that attack is effective. Hitboxes and hurtboxes are specialized collision checks (collision checks allow you to determine when objects come in contact or overlap). Written in October 2017 by Nathan Ranney, the founder of game development studio Gutter Arcade.
0 Comments
Leave a Reply. |