🦸🏻 Player: Player Melee

Now, we will create a melee attack with a sword. Of course, there are many ways you can do this, and the method below is just the one I use.

First, you will need a sprite of the character attacking with a sword, along with the Hendrix Animation Solution and Hendrix Keyboard Gamepad plugins. You just need to enable them. The Animation Solution is used to break the animation limits of RPG Maker, and the Keyboard Gamepad allows you to map any key on both the keyboard and the gamepad.



We will create a conditional branch Input.isTriggered('a'). If the player presses A, we will change the graphic of the player and run the slashing animation by using Movement Route playFrames(1, 6, 3). This means I'll play from the first frame to the last frame with a speed of waiting 3 frames between changing to the next frame.

So, we've completed the animation part for the character. Now, we need to make the sword capable of dealing damage to enemies. We will use Create Dynamic Events plugin command to create an event that lasts for 3 frames with the notetag <weaponAttack>. Why don't I use <dmg> here? You could use it as well, but there's a way to make the system automatically use weapon damage from the database. After that, don't forget to change the player graphic back to idle one.


In the common event for enemy collision from previous tutorials, let's add a conditional branch to check for collision with the notetag <weaponAttack> and leave the HP Change field blank; instead, we select "Use Weapon DMG slot1", and that's it.


MORE ACCURATE METHOD

This method is very quick, but not overly accurate, because we create the hitbox before/after the animation runs. We don't want monsters to take damage before the player has swung their weapon, nor do we want the damage to be applied only after the player has completed the slashing animation. If your game doesn't require high precision, this method is quite convenient.


Here's a method with higher accuracy. We'll use toFrame to manually run to a specific frame in the spritesheet. Here, in the player's spritesheet, the player starts swinging the sword at frame 3, so I'll use toFrame to get to frame 3 before creating the hitbox. Then, it's just a matter of using playFrames to let the system automatically run through the remaining frames.


To make it even more accurate, you'll need to create hitboxes with different sizes for the player's horizontal and vertical directions because, in the spritesheet above, you can see that the sword points downward and has a considerable length. Combining Create Dynamic Event with Conditional Branches for player direction (left, right, up, down), you'll achieve a more precise result, offering a better experience for the player.




5 RPG Maker Action Combat Manual: 🦸🏻 Player: Player Melee Now, we will create a melee attack with a sword. Of course, there are many ways you can do this, and the method below is just the one I use....
< >