Customization
Teams, tuning, damage and multiplayer. The names of all properties and functions are in the Blueprint Reference.
Teams
Every turret has a TeamID (byte, 255 = no team). The controller copies it from the turret it possesses and decides with the engine's default rule:
| 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 |
Giving the player a team
A pawn has a team when it, or its controller, implements BPI_TeamAgent → GetTeamID. Either:
- set
Blueprints/Examples/BP_TeamPlayerControlleras your GameMode's Player Controller Class and set itsTeamID, or - add
BPI_TeamAgentto your own controller or pawn (Class Settings → Interfaces) and implementGetTeamID.
Changing teams at runtime
Turrets do not notice team changes on their own. After changing a team, call OnTeamsChanged on every BP_TurretAIController, as BP_TeamPad does.
Your own friend/foe rule
Create a child of BP_TurretAIController, override GetTeamAttitude and return the attitude you want. BP_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 BP_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 BP_TurretAIController:
| Property | Default | Meaning |
|---|---|---|
ShootProjectileTimerRate | 0.7 | Seconds between shots |
TrackPlayerTimerRate | 0.1 | Seconds between aim updates |
TrackingTimeout | 3.0 | Seconds without a hostile in sight before the turret resets |
ShootingActive, TrackingActive | true | Switch firing or tracking off |
Projectile speed and barrels
On the turret:
| Property | Meaning |
|---|---|
VelocityScale | Projectile speed in cm/s. The base class uses 1000, the two turrets 4000 |
bDualBarrel | Fire from both barrels |
DualBarrelShootDelay | Delay of the second barrel |
ProjectileClass | Projectile to spawn, BP_TurretProjectile by default |
The lead calculation uses VelocityScale, so faster or slower projectiles still hit.
Projectiles expire after 5 seconds (InitialLifeSpan on BP_TurretProjectile): 200 m at 4000 cm/s. Raise it for turrets that fire farther.
Health and damage states
On the turret's HealthComponent (AC_Health): MaxHealth (default 100) and bDamageImmune.
Damage states are three parallel arrays on the turret: DamageStateThresholdPercentages (0.75, 0.5, 0.25), DamageStateEffectClasses (BP_DamageState_Sparks, _Smoke, _Fire) and DamageStateEffectOffset. Add, remove or replace entries to change them. The debris actor is DestroyedActorClass.
Damage
Turrets take damage through the engine's Apply Damage, so any Blueprint can damage them. ChangeHealth on AC_Health heals with a positive value.
The turret's projectiles deal no damage by default. OnProjectileImpact on BP_TurretPawnBase is empty. To make them hurt:
- Create a child of
BP_TurretPawn(or open your own turret). - Override the function
OnProjectileImpact. - Call Apply Damage with
OtherActoras the damaged actor.
Every machine spawns its own projectiles, so OnProjectileImpact runs on every machine. Put a Has Authority check in front of Apply Damage, or clients apply the damage too.
Health, damage feedback and destruction can be reacted to through the dispatchers on AC_Health: OnHealthChanged, OnDeathStarted, OnDeathFinished.
Multiplayer
- Health and death state replicate. Damage states, damage numbers, the health bar and destruction run on clients through RepNotifies.
- Shots are a multicast: every machine spawns its own, unreplicated projectiles.
- The turret's aim (
TurretRotation) replicates.
The example map has been played in multiplayer by hand. There is no automated multiplayer test.
Your own turret model
- Create a child of
BP_TurretPawnBase. - On MeshComponent, set your skeletal mesh and an Animation Blueprint that rotates the head from the turret's
TurretRotation(seeABP_Turret). - Add sockets for the muzzle and, for two barrels, a left and right muzzle. Set their names in
Name_SocketMuzzle,Name_SocketMuzzleLeftandName_SocketMuzzleRight(defaultsmuzzle,muzzle_left,muzzle_right). - Set AI Controller Class to
BP_TurretAIControlleror a child of it.
Effects and sounds
On the turret: ShootSound, ResetTurretSound, DamageSound, DestructionSound, MuzzleFlashEffect and ProjectileEffect. Override SpawnShootFX for a custom muzzle effect.
Things to know
- A turret's own shots fly through each other, so the converging shots of a dual-barrel turret do not collide. Shots of different turrets do collide.
- Aiming assumes a target standing on the turret's floor. The turret aims at a Character's feet, and the muzzle height lifts the shot into the capsule. Flying or small non-Character targets are overshot by about the muzzle height.
- Turrets can be scaled. The health bar, damage numbers and debris follow the actor scale.
HealthBarHeightis given at scale 1.