Local Multiplayer Self Damage Problem
When either player is behind another they can deal damage I do this by getting input key down time while a bool is set from the collision behind the player and when the key down is greater than 0 it will subtract health from the player.
My problem is that when I am behind the player I can damage them fine and only their health goes down but when I go infront of the player and then press the same action it will take away my health even though I'm attacking and not the other player.
Both actors are spawned from the same character bp and I assume the problem derives from it using the player controller since its index is 0 and doesnt account for the other players.
How would I go about fixing this? How do I only subtract health from the player that Im behind and prevent myself from damage when they are behind me?
Every other variable is set in the widget so it uses get owning player pawn so each character has their own individual variables its only the damage that is being set from inside the player bp itself so yeah Im not sure to how to go about this.
asked Feb 21 '19 at 10:54 PM in Blueprint Scripting
you basically just need to have a way to reference the actor your overlapping so that you can damage them. below is a little example i threw together that should work in your situation, though im sure theres a better way to go about it. what i did is when the input is pressed i got all actors of the class that can be damaged then for each one i checked to see if i was overlapping their damage box. if true then i apply damage. the cast should be superfluous but my editor was being weird about it so i added it in.
Follow this question
Once you sign in you will be able to subscribe for any updates here