Approach to a sword slash battle mechanic

Hello, I have my main character that walks around etc. I am starting to implement my battle mechanics, and would like to ask if this is the right way to approach this battle mechanic.

When I hit the action button I would like him to do a sword slash action, but the sword itself should follow different physics. I thought maybe I should do the sword animation, but draw another sword “on top” that follows the animation that has its own physics and would disappear/reappear on every tap event (Is this efficient that won’t slow down the game?). Or am I approaching this totally wrong? 

I do have Physics Editor where I thought maybe I could use a normal spritesheet of entire guy and just seperate the image into a weapon/player physics that I just shape myself, instead of drawing a sword on top. But not too sure if that is the right way?

Thanks for the help!

Your making a tile based game in MTE right?

If so, why not just see if the characters are touching, and if the player is attacking, deduct x amount of hp from the enemy, and vice versa, on every sword slash.

Apologies if I didn’t get your situation correctly.

Hey thanks for the post, it is done using Tiled in MTE. But I figured if I did a front sword slash and kept it based if they are touching, I would think that it would register on the entire body of the player so a monster behind me touching me would still get hurt and not based on the actual sword? Also I thought I would need to make the sword a sensor so it could go right through the monster. Which would have to change the physics on the fly on action all the time, and I should stay away from that.

I think I am mostly confused on how to approach the player attacking part, I figured I would do HP deduction based on contact with the sword collision

I think the solution to this problem is to do a “direction” check. Pseudo code:

If player is facing monster and attacking then deduct hp.

The same works in reverse for how this could be handled for monsters that are attacking the player.

Does that help? 

That does help, and actually reading your comments on another posted helped more on this topic too. I ended up checking the direction of player and hiding their spritesheet(image), made a new sprite on top visible with attack animation and created a physics box around the entire sword range for that animation *one big box :frowning: *, and after a short delay it removes that physics box and makes normal player walking animation visible again, and hides the attack animation spritesheet.

I had a concern with performance on this where I create and delete the physics on the fly and and of course when it is created and a monster is touching this physics box( of the sword where its deleted a fraction of a second after) would this be ok to check collision on it in the future when its being deleted and created so quickly and would I come across any fps/memory issues down the road? Trying to make a solid battle without going down a bad road here.

Your making a tile based game in MTE right?

If so, why not just see if the characters are touching, and if the player is attacking, deduct x amount of hp from the enemy, and vice versa, on every sword slash.

Apologies if I didn’t get your situation correctly.

Hey thanks for the post, it is done using Tiled in MTE. But I figured if I did a front sword slash and kept it based if they are touching, I would think that it would register on the entire body of the player so a monster behind me touching me would still get hurt and not based on the actual sword? Also I thought I would need to make the sword a sensor so it could go right through the monster. Which would have to change the physics on the fly on action all the time, and I should stay away from that.

I think I am mostly confused on how to approach the player attacking part, I figured I would do HP deduction based on contact with the sword collision

I think the solution to this problem is to do a “direction” check. Pseudo code:

If player is facing monster and attacking then deduct hp.

The same works in reverse for how this could be handled for monsters that are attacking the player.

Does that help? 

That does help, and actually reading your comments on another posted helped more on this topic too. I ended up checking the direction of player and hiding their spritesheet(image), made a new sprite on top visible with attack animation and created a physics box around the entire sword range for that animation *one big box :frowning: *, and after a short delay it removes that physics box and makes normal player walking animation visible again, and hides the attack animation spritesheet.

I had a concern with performance on this where I create and delete the physics on the fly and and of course when it is created and a monster is touching this physics box( of the sword where its deleted a fraction of a second after) would this be ok to check collision on it in the future when its being deleted and created so quickly and would I come across any fps/memory issues down the road? Trying to make a solid battle without going down a bad road here.