Advanced Turret System
  • Welcome
  • Getting Started
    • Quickstart
    • Demo Scene Overview
  • Basics
    • Manual Turret Setup
    • TurretController Inspector
    • Turret Projectiles & Customization
  • Extra
    • Health System
Powered by GitBook
On this page
  • Turret Projectiles & Customization
  • πŸš€ Two Modes of Fire
  • 🧩 Required Setup (for custom projectiles)
  • πŸ› οΈ Key Settings (TurretProjectile)
  • ⚑ Events
  • πŸ’‘ Notes
  • πŸ“¦ Creating a Custom Projectile
  1. Basics

Turret Projectiles & Customization

Turret Projectiles & Customization

Turrets in this system can use either physical projectiles or raycasts. This page explains how projectiles work and how to create your own.


πŸš€ Two Modes of Fire

1. Projectile Mode

  • Spawns a physical object using a prefab.

  • Requires a Rigidbody and the TurretProjectile script.

  • Supports Directional (straight line) or Homing movement.

2. Raycast Mode

  • No physical bullet β€” instant hit is simulated via raycast.

  • The TurretProjectile still gets instantiated to handle hit VFX and custom logic.


🧩 Required Setup (for custom projectiles)

Every projectile prefab must have:

  • βœ… TurretProjectile component

  • βœ… Rigidbody (set to useGravity = false)

  • βœ… Collider (usually a SphereCollider, set as isTrigger = true)

These are added automatically if you use the menu: GameObject β–Έ Turret β–Έ Create Turret Projectile


πŸ› οΈ Key Settings (TurretProjectile)

Field
Description

Mode

Directional (straight shot) or Homing (tracks a target)

Speed

How fast the projectile travels (units/sec)

Life Time

Auto-destroys after this many seconds

Rotation Speed

How quickly the homing projectile can turn

Collision Layers

Which layers this projectile can hit

Hit Effect Prefab

Optional VFX spawned on impact

Hit Effect Lifetime

Time before hit effect is destroyed


⚑ Events

enemyHit(GameObject, float)

This UnityEvent is triggered when the projectile hits an enemy. You can use it to:

  • Play custom effects

  • Trigger animations

  • Apply extra logic to the hit object


πŸ’‘ Notes

  • Raycast projectiles simulate impact, but don't move β€” they rely on a fake visual trail if desired.

  • Physical projectiles should always use Rigidbody.linearVelocity, not physics forces.

  • Homing mode uses Transform.LookRotation toward the target and adjusts over time.


πŸ“¦ Creating a Custom Projectile

  1. Duplicate an existing projectile prefab

  2. Replace the visual model (optional)

  3. Adjust inspector values like speed, damage, etc.

  4. Assign to your turret’s Projectile Prefab field

  5. Done!

Or use the editor menu to auto-create one: GameObject β–Έ Turret β–Έ Create Turret Projectile

For advanced setups, you can subclass TurretProjectile to extend behavior.

PreviousTurretController InspectorNextHealth System

Last updated 13 days ago