How do I make a player only take damage from a specific enemy?

I am making a two player co-op game where the players can only take damage from the same colored enemies. I’m looking at the mechanics from Ikaruga as reference.

So my question really has two parts:

  1. How do I set player colors while only using one blueprint (same blueprint script)?
  2. How do I have a player/enemy take/deal damage to the same colored enemy?

Thanks in advanced!


So you have two actors which are childs from the same blueprint and you want something to identify who is who ingame. You may start adding a variable called “color” on the character blueprint and set its type to “name”, then, when you spawn those actors you set the variable of the first character you spawn to “blue” and the second to “red” (take in mind this is only a example).

At the part of the blueprint where the damage is applied, you check first for the colors doing a CastTo the parent blueprint, get the color from the variable you have set and check if the names are equal.