Customization Guide
Learn how to customize and extend the AI Turret plugin to fit your specific game requirements.
Basic Customization
Adjusting Detection Range and Angle
To modify how far and wide your turrets can detect enemies:
- Open your turret's AI Controller (e.g.,
B_TurretAIController
) - Select the AI Perception Component in the Components tab
- In the Details panel, navigate to AI Perception → Senses Config → Index [0] → Sense
- Modify these values:
- Sight Radius: Maximum detection distance (e.g., 2500.0 cm)
- Lose Sight Radius: Distance at which turret loses target (should be higher than Sight Radius)
- Peripheral Vision Half Angle: Field of view (90° = 180° total FOV, 180° = full circle)
Projectile Speed Configuration
Adjust projectile speed based on your game's pace:
TurretPawn Settings
- Velocity Scale: Multiplier for projectile velocity (recommended: 2000.0 for 20m/s)
TurretAIController Settings
- Tracking Correction: Lead angle adjustment
- Fast projectiles (high Velocity Scale): Use values between 0-1
- Slow projectiles (low Velocity Scale): Use values between 1-2
Fire Rate Adjustment
Control how often turrets shoot:
- Open your
B_TurretAIController
- Modify Shoot Projectile Timer Rate (default: 0.7 seconds)
- Lower values = faster firing
- Higher values = slower firing
Tracking Behavior
Fine-tune how turrets track targets:
- Track Player Timer Rate: How often turret updates target position (default: 0.1s)
- Tracking Timeout: How long turret waits before returning to base position when target is lost
Friend/Foe Detection
Using Team System
The plugin uses Unreal's team system for friend/foe detection:
Setting Up Team-Based Player Controller
- In your Game Mode, set the Player Controller Class to
B_TeamPlayerController
- Set the Team ID property on both turrets and players
- Team ID 0 = Neutral
- Team ID 1+ = Specific teams
Custom Friend/Foe Logic
Override the GetTeamAttitude
function in your AI Controller:
// In Blueprint, override GetTeamAttitude function
// Example: Always treat specific actor classes as friendly
if (ActorToCheck->IsA<ASpecialFriendlyCharacter>()) {
return ETeamAttitude::Friendly;
}
return Super::GetTeamAttitude(ActorToCheck);
Team Testing Utilities
Use the included test blueprints:
- B_TeamPad: Step on it to change your team ID
- B_TurretAIController_AlwaysFriendly: Never attacks anyone (for testing)
Visual Customization
Replacing the Turret Model
To use your own turret model:
- Create a new Blueprint extending
TurretPawn
- Replace the Skeletal Mesh Component with your model
- Ensure your model has the required sockets:
- Muzzle socket (for targeting traces)
- Left/Right muzzle sockets (for projectile spawn points)
- Update socket names in the turret's properties
Custom Materials and Textures
- Navigate to Plugins → AITurret Content → Turret → material
- Duplicate existing materials
- Modify textures and material properties
- Apply to your turret's skeletal mesh
VFX Customization
Replace Niagara effects:
- Muzzle Flash Effect: Visual effect when firing
- Projectile Effect: Trail/glow effect on projectiles
- Impact Effect: Effect when projectile hits something
Audio Customization
Sound Effects
Replace audio files in Plugins → AITurret Content → Turret → audio:
- Fire Sound: Played when turret shoots
- Impact Sound: Played when projectile hits
- Mechanical Sounds: Turret movement audio
3D Audio Setup
Configure audio attenuation for realistic sound falloff:
- Create Sound Attenuation assets
- Apply to sound effects in turret blueprints
- Adjust distance and volume curves
Advanced Customization
Creating Custom Projectiles
- Create a new Blueprint extending
TurretPlasmaProjectile
- Modify physics properties:
- Projectile Gravity Scale: 0 = no drop, 1 = realistic physics
- Initial Speed and Max Speed
- Bounce properties for ricocheting projectiles
- Add custom collision logic
- Set the new projectile class in your turret's Projectile Class property
Custom AI Behaviors
Create specialized AI controllers:
Patrol Turret
// Add patrol points and movement logic
// Rotate between multiple positions
// Different detection ranges at different positions
Burst Fire Turret
// Modify firing logic to shoot multiple projectiles in quick succession
// Add cooldown periods between bursts
Predictive Turret
// Enhanced lead calculation
// Account for player acceleration patterns
// Adaptive tracking based on player behavior
Animation Customization
Custom Animation Blueprint
- Create new Animation Blueprint for your turret model
- Implement these key features:
- Turret Rotation: Smooth interpolation to target rotation
- Recoil Animation: Visual feedback when firing
- Idle Animations: Subtle movements when not tracking
Bone Structure Requirements
Your turret model should have bones for:
- Base rotation (horizontal turning)
- Barrel elevation (vertical aiming)
- Recoil movement (firing feedback)
Performance Optimization
LOD (Level of Detail) Setup
- Create multiple mesh versions with different polygon counts
- Set up LOD groups in your skeletal mesh
- Configure distance-based switching
AI Perception Optimization
- Increase Track Player Timer Rate for distant turrets
- Use different AI controllers with varying update frequencies
- Implement culling for off-screen turrets
Integration Examples
Damage System Integration
// In OnProjectileImpact event
if (HitActor->IsA<ACharacter>()) {
ACharacter* HitCharacter = Cast<ACharacter>(HitActor);
// Apply damage using your game's damage system
HitCharacter->TakeDamage(DamageAmount, DamageEvent, GetController(), this);
}
Health System for Turrets
// Add health component to turret
// Handle destruction when health reaches zero
// Add visual damage states (sparks, smoke, etc.)
Power System Integration
// Add power requirements
// Disable turrets when power is low
// Different power consumption for different firing modes
Blueprint Examples
Multi-Barrel Turret Setup
- Enable Dual Barrel in turret properties
- Set Dual Barrel Shoot Delay for staggered firing
- Configure left and right muzzle sockets
- Adjust animation blueprint for dual recoil
Sniper Turret Configuration
// High damage, slow fire rate
Shoot Projectile Timer Rate = 3.0f
Velocity Scale = 5000.0f
Sight Radius = 5000.0f
Tracking Correction = 0.1f
Close-Range Defense Turret
// Fast firing, short range
Shoot Projectile Timer Rate = 0.2f
Velocity Scale = 1500.0f
Sight Radius = 1000.0f
Peripheral Vision Half Angle = 180.0f
Testing and Debugging
Debug Visualization
Enable AI debugging to see:
- Sight cones and detection ranges
- Target tracking lines
- Projectile trajectories
Performance Profiling
Use Unreal's profiling tools:
- Stat AI for AI performance
- Stat Game for overall performance
- Stat Niagara for VFX performance
Need help with advanced customization? Join our Discord server for community support and examples!