Customization
Teams, tuning, damage, multiplayer and your own turret model. The names of all properties and functions are in the Blueprint Reference.
Teams
The plugin uses Unreal's IGenericTeamAgentInterface, the team interface of the engine's AI. Every turret has a TeamID; the controller copies it from the turret it possesses. A team ID of 255 means no team.
GetTeamAttitude on the controller decides how the turret treats an actor:
| Other actor | Attitude |
|---|---|
| Pawn of the same team | Friendly, ignored |
| Pawn of another team | Hostile, attacked |
| Pawn without a team | Hostile, attacked |
| Anything that is not a pawn | Neutral, ignored |
A pawn has a team when the pawn itself or its controller implements IGenericTeamAgentInterface.
Giving the player a team
- Set
Examples/Blueprints/B_TeamPlayerControlleras your GameMode's Player Controller Class and set itsTeamID, or - derive your own player controller from the C++ class
ATeamPlayerController, or - implement
IGenericTeamAgentInterfaceon your own pawn or controller in C++.
Changing teams at runtime
The turret's AI perception keeps its view of an actor until it is updated. After changing a team, call Request Stimuli Listener Update on the AIPerception component of every ATurretAIController, as B_TeamPad does.
Your own friend/foe rule
GetTeamAttitude is a Blueprint Native Event. Create a child of B_TurretAIController, override GetTeamAttitude and return the attitude you want; call the parent to keep the default rule for the other cases. B_TurretAIController_AlwaysFriendly returns Friendly for everyone. Set your controller as the turret's AI Controller Class.
Tuning
Detection range and field of view
Open the controller (for example a child of B_TurretAIController), select the AIPerception component and go to AI Perception → Senses Config → Index [0] → Sense:
- Sight Radius: maximum detection distance
- Lose Sight Radius: keep it a little higher than Sight Radius
- Peripheral Vision Half Angle: 90° gives a 180° field of view
Fire rate and tracking
On the controller:
| Property | Default | Meaning |
|---|---|---|
ShootProjectileTimerRate | 0.7 | Seconds between shots |
TrackPlayerTimerRate | 0.1 | Seconds between aim updates |
TrackingTimeout | 3.0 | Seconds without the target in sight before the turret resets |
ShootingActive, TrackingActive | true | Switch firing or tracking off |
Projectile speed and barrels
On the turret:
| Property | Default in C++ | Meaning |
|---|---|---|
Projectile Velocity (VelocityScale) | 1000 | Projectile speed in cm/s |
bDualBarrel | false | Fire from both barrels |
DualBarrelShootDelay | 0.2 | Seconds before the second barrel fires |
ProjectileClass | ATurretPlasmaProjectile | Projectile to spawn; B_TurretPawn uses B_TurretProjectile |
The lead calculation uses the projectile velocity, so faster or slower projectiles still hit. No correction factor is needed.
Damage
The projectiles deal no damage by default. They destroy themselves on impact and call the turret's OnProjectileImpact event. To make them hurt:
- Open
B_TurretPawnor a child of it. - Implement the event
OnProjectileImpact. - Call Apply Damage with
OtherActoras the damaged actor, or apply a Gameplay Effect as in the Lyra Integration.
Every machine spawns its own projectiles, so OnProjectileImpact runs on every machine. Put a Has Authority check (Switch Has Authority) in front of the damage, or clients apply it too.
The turrets themselves have no health in this version. To make them destructible, add your own health component and handle Any Damage on the turret.
Multiplayer
- The AI controller runs on the server only.
- The turret's aim (
TurretRotation) replicates; the Animation Blueprint reads it on every machine. - Shots are a multicast: every machine spawns its own, unreplicated projectiles and plays the muzzle flash and sound.
- The reset sound plays on every machine.
Your own turret model
- Create a Blueprint child of
ATurretPawn, or ofB_TurretPawnto keep the effects and sounds. - On MeshComponent, set your skeletal mesh and an Animation Blueprint that rotates the head and barrel from the pawn's
TurretRotation(seeABP_Turret).TurretRotationis relative to the turret's base. - Add sockets for the muzzle and, for two barrels, a left and right muzzle. Set their names in Muzzle Socket, Left Muzzle Socket and Right Muzzle Socket (defaults
muzzle,muzzle_left,muzzle_right). - Set AI Controller Class to
B_TurretAIControlleror a child of it.
A single-barrel turret fires from Muzzle Socket. A dual-barrel turret fires from the left socket first and from the right one after DualBarrelShootDelay.
Your own projectile
Create a Blueprint child of ATurretPlasmaProjectile (or of B_TurretProjectile). Its ProjectileMovementComponent has no gravity by default; raise Projectile Gravity Scale for a ballistic arc, but note that the lead calculation assumes a straight line. Set the new class as the turret's ProjectileClass.
Effects and sounds
On the turret: ShootSound, ResetTurretSound, MuzzleFlashEffect and ProjectileEffect. Override SpawnShootFX for a custom muzzle effect. The muzzle flash receives the shot direction in its Direction variable.
Things to know
- Aiming assumes a target standing on the turret's floor. The turret aims at a Character's feet from its base, and the muzzle height lifts the shot into the capsule. Flying or small non-Character targets are overshot by about the muzzle height.
- Dual barrels fire parallel. Both shots fly in the same direction, offset by the distance between the barrels.
- Projectiles fly until they hit something. Give your projectile class an Initial Life Span if turrets fire into open space.