Disable Friendly Fire in ActionRPG template

Hey everyone,

Short Question: How can I stop Actors with same tag damaging each other (skill attack, melee, projectile and etc.).

Details: I’m trying to create a diablo like game using AcrionRPG template. Similar to diablo, my screen also gets filled with different enemies. The problem is that these enemies can damage each other and kill each other without the player ever attacking them. You can see this problem by completing two or three waves in the AcrionRPG template and wait for the giant spider to spawn. This giant spider attacks easily kill other creeps(NPC_GoblinBP). This seems like a fine feature in a game with relatively low number of characters in it. But in my game when several normal enemies along with some bosses spawn in level it tends to get ridiculous.

An other problem is that I have created a companion for my character that finds enemies using their tags and attack them. The AI class and my character works fine but when I use an ability near this companion or attack him, it takes damages and eventually die! which is a nightmare for me.

I looked at the blueprints and didn’t find any solutions. I traced TryActivateAbilitiesByTag in the BP_Character to its roots, but my lack of practice with C++ finally came to hunt me and I got lost.

Any answers or suggestions would be greatly appreciated.

It looks like damage is done using notifies on animations and also the weapon actor collision. Look inside the WeaponActor blueprint and you’ll see ActorBeginOverlap.

Seems like they see if the class of the enemy and the actor in the collision are the same. What you could do here instead is compare a faction or team enum or something, that you can create and add to the base character class, then in this event you cast to the base character class, get the team enum, and check.

You could make the enum in Blueprint or C++ (just make sure to expose it to blueprints). You could also use GameplayTags, which ActionRPG uses extensively.

1 Like

Dear @Cd1232 , Thank you very much
Based on your suggestion I was able to achieve my goal for normal melee attack and projectile based attack. What I did for the melee weapon attack was that along with ignoring the instigator collision, I also searched for the same team tags (GetAllActorsWithTag function) and ignored them too. A similar process can be done for the projectile class.

My problem however is with the skill attack. Take this fairly straightforward example: the main character (BP_PlayerCharacter) cast a spell with keyboard key “F”. The DoSkillAttack function is called and its target is BP_Character. Then in BP_Character, ActivateAbilitiesWithTag is called. When I double click on that, it jumps into C++ and ActivateAbilitiesWithTags
function, which calls for TryActivateAbilitiesByTag which itself after checking for abilities with the specified tag calls TryActivateAbility which ultimately calls for ClientTryActivateAbility when I go to this function definition I get lost, and I cant go further.

I dont know much about the ability system, But I think there must be an easier way! the GA_AbilityBase blueprint has some excellent features. UE4Editor_2021-04-23_14-40-47
like Target Required Tags, Target Blocked Tags which I believed for are designed exactly to do such things. But I really don’t know know I can work with the. How can I add for example a Friendly.Fire.Off gameplay ability or something like that?

again thank you @Cd1232, my combat feels much smoother now! :slightly_smiling_face:

P.S. In the GE_PlayerSkillMeteor I was able to find this:


which has ignore tags under target tags, which I thing might help me. I will try to work with it and post the result here.

So rather than looking at GE_PlayerSkillMeteor, what you probably want to do is again edit the collisions.

If you look at BP_AbilityProjectileBase that has another ActorBeginOverlap which checks the instigator, so you wanna check for tags here

Rather than GetAllActorsWithTag, I’d suggest you compare the team from the instigator (who the ability came from), and the hit actor.

You could create an Enum in blueprints called Faction with Player and Enemy as 2 values, Add that to the BP_Character, then you can set the BP_PlayerCharacter to Player faction, and the BP_EnemyCharacter to Enemy faction.

From there you can then cast the instigator and the hit actor to BP_Character, get the faction, and use != to make sure they’re not the same

Well, The problem is that most skills don’t work with collisions! When they are triggered they apply an effect to all nearby actors.