How do I get rid of friendly fire

Hi everyone! In my game I have two AI team that will attack each other. But the AI seem to accidently hurt there own teammate sometimes. How do I make sure the AI wont apply damage to there own teammate. I tried some attempts by checking if the actor has a Tag that says either team1 or team2 then put it into a branch but for some reason a huge amount of errors come up.

Have you tried using Instigated By and making sure to set the correct actor when you’re applying the damage?

If you still get errors doing that it would be helpful to post those as well.

Hi there! I just tried your suggestion but it seems like the same problem keeps on happening along with many errors!

tion alt text

Are you using the “Apply Damage” Node?
If yes, make sure to actually connect the Event Instigator reference to the responsible Player Controller.
You could add a team variable to the Player Controller and as you pass it through the “Apply Damage” node, get it from the Event AnyDamage → InstigatedBy → Cast to that Player Controller and get the team variable to compare and adjust your logic there.

I figured it out by using the “Out Hit Actor” on the sphere trace by channel node then checked if actor had tag then everything worked. No clue why it did not work for the other ones but everything works.