Skip to main content

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:

  1. Open your turret's AI Controller (e.g., B_TurretAIController)
  2. Select the AI Perception Component in the Components tab
  3. In the Details panel, navigate to AI PerceptionSenses ConfigIndex [0]Sense
  4. 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:

  1. Open your B_TurretAIController
  2. 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

  1. In your Game Mode, set the Player Controller Class to B_TeamPlayerController
  2. 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:

  1. Create a new Blueprint extending TurretPawn
  2. Replace the Skeletal Mesh Component with your model
  3. Ensure your model has the required sockets:
    • Muzzle socket (for targeting traces)
    • Left/Right muzzle sockets (for projectile spawn points)
  4. Update socket names in the turret's properties

Custom Materials and Textures

  1. Navigate to PluginsAITurret ContentTurretmaterial
  2. Duplicate existing materials
  3. Modify textures and material properties
  4. Apply to your turret's skeletal mesh

VFX Customization

Replace Niagara effects:

  1. Muzzle Flash Effect: Visual effect when firing
  2. Projectile Effect: Trail/glow effect on projectiles
  3. Impact Effect: Effect when projectile hits something

Audio Customization

Sound Effects

Replace audio files in PluginsAITurret ContentTurretaudio:

  • 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:

  1. Create Sound Attenuation assets
  2. Apply to sound effects in turret blueprints
  3. Adjust distance and volume curves

Advanced Customization

Creating Custom Projectiles

  1. Create a new Blueprint extending TurretPlasmaProjectile
  2. Modify physics properties:
    • Projectile Gravity Scale: 0 = no drop, 1 = realistic physics
    • Initial Speed and Max Speed
    • Bounce properties for ricocheting projectiles
  3. Add custom collision logic
  4. 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

  1. Create new Animation Blueprint for your turret model
  2. 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

  1. Create multiple mesh versions with different polygon counts
  2. Set up LOD groups in your skeletal mesh
  3. 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

  1. Enable Dual Barrel in turret properties
  2. Set Dual Barrel Shoot Delay for staggered firing
  3. Configure left and right muzzle sockets
  4. 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!