Hello to the Unreal community!
I’ve been working on fixing how my players deal damage to each other, and I think i figured out what the issues is, only I don’t know how to fix it… I have 2 players that I’m spawning in editor, both characters have the same sword equipped in a socket. When the player presses attack, it swings the weapon and activates/deactivates the collider with animnotifies. Damage is dealt to the enemy player if the sword hits, however, if you go too close to the enemy (enemy sword is colliding with your hitbox) when activating the swing, the enemies sword collider is activated also. How can i Define Which sword is activated based on who is swinging?
Hi Samuelb, could include screenshots of your blueprinting please?
Ah, the issue is that you’re getting all of the Katana BPs and then setting the collision on all of them.
You should store a reference to the player in the animation blueprint. When you set the collision of the katanas then find the katana that’s attached to the stored player reference.
If there is something specific you want to see, just tell me and I’ll post it =)
Do you mean something like this? See picture.
Could I just cast off of 0_base bp in the animation blueprint?
I’m spawning the katana’s into the socket on beginplay, that seems to be making them difficult to reference ;E.
Okay, it should be more like this:
In your case you will want to get “current wep” from the player.
As a side-note: getting all actors of class won’t necessarily order them in the way you’ll need them. So getting the first player in the player array might not actually get player one.
Hi again, thanks for that, i tried something similar without success, i’ll give it another try. Do you mean that when i’m getting my players from class they will go in random order sometimes?
This works for player 1 correctly, but player 2 can still die if he’s too close to player 1
You’re still setting the collider for both players! If you have both players connected to the “Enable Katana Coll” node then they’re both going to have their katana colliders enabled.
If you “get owner” from the animation blueprint then you’ll be returned with the player that’s swinging the sword. Get the katana collider from that player and set it.
Could you show an example of what you mean? I don’t quite understand, sorry.
Wow, I’m always overcomplicating things for myself, it works now as intended! Thank you very much good sir! =)
Replace the “ronin” cast-to with whatever your player is.
That’s great to hear!
Could you mark that last picture as the correct answer so other people can easily see it?