Dealing damage melee multiplayer 2 playercharacters

Hi

I’m making a 1 vs 1 swordfighting game and have been tackling with several issues.
Recently I’ve been having an issue with getting my katana/sword to deal damage only to the other player. I suspect it has something to do with how i’m spawning the katana/sword to the actors or how i’m enabling/disabling the colliders on it.

Basicly what happens is when i hit the other player from far, that player loses health correctly, but if i get too close the enemies sword and attack, they both take damage. Should I be using some sort of tagging system to determine which character ignores the damage? And if so how would i go about doing it.

Thanks in advance
Samuel Brooke

max hp = 2.0

pictures:
hit from far

hit from close

Maybe if you’re too close the collider of the other katana hits your character, as I can see in the hit from close picture your character is very near the enemies katana.

Hi thanks for the reply and yes, thats exactly what is happening. My point was that I am spawning the same katana, even though i activate the katana on player1 it also activates the katana on player 2.

Hi and thanks for the reply, The collider is enabled using rep notifies on the animation. So when the Hit animation is activated, the katana’s collider will activate and deactivate between “rep enable collider”," rep Disable collider" if that makes any sense. I’ll provide the requested code for you in abit. As for using ramas plugins, I’ve thought of that before, but I would like to leave that as a last resort. I don’t recall there being anything about player vs player hit detection in that?

  • SamuelB

Here are some screenshots, hopefully they will help to clarify the situations.

  • SamuelB

can you show the code where you actually do the hit detection - does the “hit” require the player be swinging the weapon? you can also maybe check to see if the weapon is hitting its holding player

perhaps check out ramas weapon plugin, might be worth using, or pulling apart to learn from - Rama Melee Weapon Plugin Intro - YouTube

I’ve also tested that the collider is not hitting the players own collider, I had that issue earlier and solved it by making the notify threshold alot smaller (so it only activates at the very end of the swing) and by moving the sword collider more towards the end of the katana.