I just downloaded Lyra and made a weapon but, I’ve been trying to turn off the protection for friendly fire. I want friendly fire to be active.
I’ve been looking through the blueprints and C++ files and nothing I change seems to allow for friendly fire. Can someone tell me what line to change or what blueprint this team comparision for friendly fire is happening and preventing it? Is there a tutorial? I couldn’t find anything in the documentation either. Where can I disable this check?
Also, if these are the correct files, is it possible I’m using a wrong compiler? I’m currently using VSCode as I tried it with unreal 4 and it worked quite well.
Hello, I recently came across the same problem. But I found the right place to handle friendly fire: the solution was not to search for friendly fire in particular, but rather for team-handling stuff.
Open the C++ file “LyraDamageExecution.cpp” and go to line “103”. There you just need to change the last value, which should be “0.0” to “1.0”, right before the “;” at the end of the line.
Recompile and then you should have friendly fire (at least that worked for me). Good luck!
Yes that’s the one. You can add that anywhere using the same setup in blueprints. I have that check in my abilities and just change the logic depending on the ability. What exactly are you trying to do otherwise?
Hi there, once I activated friendly fire using that small code, this custom damage calculation is affecting all experiences. I wanted to create a logic switching for certain types of missions or even specific damage sources, damage can be registered within same team, for instance explosions from grenades, abilities, vehicles etc, while keeping weapons with normal damage execution, or vice versa. But I wanted to keep control of this settings via blueprint. Another way that would work for me is adding a gameplay tag to the Ability bp and set friend fire ON/OFF.
The tag is something that is not clear to me for this particular case. Imagine I have only 2 teams and two scenarios:
Player Instigator - Tag Team 1
Player Target - Tag Team 1
Player Instigator - Tag Team 2
Player Target - Tag Team 2
How a gameplay tag setup inside a GA should look like to switching friendly fire on/off?
Another examples:
For playing Elimination, friendly fire is ON. Control Point is OFF
Heavy explosions: Friendly fire is ON. Weapons are OFF
Just as an update @Balive@BattLe_SCVs, I figured out a way to selectively turn friendly-fire on and off using tags. After editing the LyraDamageExecution.cpp line 103 (thanks @hevn3), I added tags Enemy and Player based off team IDs (for testing only, my prototype will have team ID ignored). To disable friendly-fire for Pistol and Rifle, GE_Damage_Pistol and GE_Damage_RifleAuto, in the Calculation Modifiers section, I added two array elements, one for enemy as source, and the second having player as source. That said, I kept GE_Damage_Shotgun with default calculation modifier, thus with friendly fire enabled. This logic can be expanded for certain experiences, level areas, etc. using tags (ignore/require) adding as much array elements as we see fit. Now I can finally get back to work with my prototype as I have the solution for friendly-fire, give abilities in runtime, and saving character settings.
I think, correct way is the add a replicated boolean (bAllowFriendlyFire) into LyraGameState class. Than you can check this variable in CanCauseDamage function in LyraTeamSubsystem class. Get game state and check this variable in the line 343. By this way you can define different FriendlyFire modes for different game modes.