Skip to main content

Lyra Integration

Turrets in Epic's Lyra sample that know Lyra's teams and deal damage through its Gameplay Ability System (GAS).

The plugin itself does not use GAS. This guide adds the damage in Blueprint, with a Gameplay Effect copied from Lyra's rifle.

Before you start​

  • A Lyra project that runs
  • The AI Turret plugin installed in it (Setup Guide)
  • Some familiarity with Lyra's teams, GAS and the ShooterCore plugin

1. Add the plugin dependency​

ShooterCore must depend on AITurret:

  1. In the Content Browser, right-click the ShooterCore Content folder and choose Plugin → Edit.
  2. Under Dependencies, add AITurret.
  3. Save and restart the editor.

2. Create the damage effect​

  1. Copy ShooterCore/Content/Weapons/Rifle/GE_Damage_RifleAuto into AITurret Content.
  2. Rename the copy to GE_Damage_Turret.
  3. Change its damage values if you like.

3. Deal damage in B_TurretPawn​

Open B_TurretPawn and implement OnProjectileImpact: behind a Switch Has Authority, get the hit actor's Ability System Component and apply GE_Damage_Turret to it.

The authority check matters: every machine spawns its own projectiles, so without it clients would apply the damage too.

4. Use Lyra's teams in B_TurretAIController​

Lyra gives its pawns teams through IGenericTeamAgentInterface, which the plugin's C++ team rule already reads. In B_TurretAIController, either delete the GetTeamAttitude override so the C++ rule applies, or make the override return the parent's result:

5. Set the turret's team​

  1. Place B_TurretPawn in your level.
  2. Set its Team ID to one of Lyra's teams, for example 1.
  3. Press Play: turrets of your team ignore you, the others fire.

6. Tune for Lyra​

  • Projectile Velocity on the turret: Lyra is fast, so try a high value such as 10000.
  • Sight Radius on the controller's AIPerception: 1500 to 3000, depending on the map.
  • Damage per hit: in GE_Damage_Turret.

Video​

Blueprint code​

B_TurretPawn: OnProjectileImpact​

Node text to paste into the Blueprint editor
Begin Object Class=/Script/BlueprintGraph.K2Node_Event Name="K2Node_Event_3"
EventReference=(MemberParent="/Script/CoreUObject.Class'/Script/AITurret.TurretPawn'",MemberName="OnProjectileImpact")
bOverrideFunction=True
NodePosX=-496
NodePosY=269
NodeGuid=72A4765F458C18C224D904943496E3EC
End Object

Begin Object Class=/Script/BlueprintGraph.K2Node_MacroInstance Name="K2Node_MacroInstance_0"
MacroGraphReference=(MacroGraph="/Script/Engine.EdGraph'/Engine/EditorBlueprintResources/ActorMacros.ActorMacros:Switch Has Authority'")
NodePosX=-160
NodePosY=272
NodeGuid=473B6B00493F50173027459CE3741B70
End Object

Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_0"
bIsPureFunc=True
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/GameplayAbilities.AbilitySystemBlueprintLibrary'",MemberName="GetAbilitySystemComponent")
NodePosX=-160
NodePosY=400
NodeGuid=D54A5D9C4A6C097D5A6C92A0622F3568
End Object

Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_2"
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/GameplayAbilities.AbilitySystemComponent'",MemberName="BP_ApplyGameplayEffectToSelf")
NodePosX=448
NodePosY=254
NodeGuid=790AC521482AA03EA707BCA5E8ACF4EF
End Object

B_TurretAIController: GetTeamAttitude​

Node text to paste into the Blueprint editor
Begin Object Class=/Script/BlueprintGraph.K2Node_FunctionEntry Name="K2Node_FunctionEntry_0"
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/AITurret.TurretAIController'",MemberName="GetTeamAttitude")
NodeGuid=A3B829E8409F398E70A9278C7ED41C89
End Object

Begin Object Class=/Script/BlueprintGraph.K2Node_CallParentFunction Name="K2Node_CallParentFunction_0"
bIsPureFunc=True
bIsConstFunc=True
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/AITurret.TurretAIController'",MemberName="GetTeamAttitude")
NodePosX=240
NodePosY=80
NodeGuid=D6949BF94958AD47EC745781D05B1D18
End Object

Begin Object Class=/Script/BlueprintGraph.K2Node_FunctionResult Name="K2Node_FunctionResult_0"
FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/AITurret.TurretAIController'",MemberName="GetTeamAttitude")
NodePosX=512
NodeGuid=9283AF6844D355D5D1D04B87BDAF9272
End Object

Troubleshooting​

Turrets attack their own team. Check that the turret's Team ID matches the player's Lyra team, and that GetTeamAttitude returns the parent's result (step 4).

Projectiles hit but deal no damage. Check that GE_Damage_Turret is set in OnProjectileImpact and that the hit actor has an Ability System Component.

Damage is applied twice in multiplayer. The Switch Has Authority in front of the damage is missing (step 3).