Projectile System
Projectile System
Section titled “Projectile System”Projectile Actor Creation
Section titled “Projectile Actor Creation”Basic Projectile Components
Section titled “Basic Projectile Components”Create a new Actor_Projectile blueprint with essential components:
Core Components
Section titled “Core Components”- Sphere Collision: Root component for physics and collision
- Static Mesh Sphere: Visual representation (attached to collision)
- Projectile Movement Component: Handles physics and trajectory
Component Configuration
Section titled “Component Configuration”- Sphere Scale: 0.5 for all axes (smaller visual projectile)
- Sphere Collision: Custom collision, ignore all, overlap pawn only
- Static Mesh: No collision, no overlap events (visual only)
- Projectile Movement: Initial speed 1000, max speed 1000, gravity scale 0
Movement Settings
Section titled “Movement Settings”Configure projectile physics for different projectile types:
- Standard Projectiles: Gravity scale 0 for straight-line travel
- Grenades: Gravity scale 1 for arcing trajectories
- Arrows/Bolts: High speed (3000) with minimal gravity
Projectile Hit Detection
Section titled “Projectile Hit Detection”Collision System
Section titled “Collision System”Implement hit detection for projectiles:
// Projectile Hit DetectionOnProjectileHitboxOverlap(OtherActor) {if (OtherActor != Owner) {if (IsChildClassOf(OtherActor, Character)) {Interface_Health_Modify(OtherActor, Subtract, Damage);StopMovementImmediately();SpawnVFXAtLocation();DestroyProjectileAfterDelay(0.2);}}}
Environmental Collision
Section titled “Environmental Collision”Enable projectile interaction with environment:
- World Static: Allow collision with static environment objects
- World Dynamic: Allow collision with moveable objects
- Hit Registration: Projectiles stop and spawn VFX on environmental hits
Spawning System
Section titled “Spawning System”Projectile Spawn Function
Section titled “Projectile Spawn Function”Create reusable function for spawning projectiles:
F_Spawn_Projectile Function
Section titled “F_Spawn_Projectile Function”- Skeletal Mesh Input: Source mesh for socket location
- Socket Name Input: Spawn location socket
- Forward Offset: Distance in front of character to spawn
- Damage Input: Damage amount for this projectile
- Speed Input: Projectile travel speed
- Gravity Input: Gravity scale for trajectory
Spawn Implementation
Section titled “Spawn Implementation”// Projectile Spawn LogicF_Spawn_Projectile(SkeletalMesh, SocketName, ForwardOffset, Damage, Speed) {spawn_location = GetSocketLocation(SkeletalMesh, SocketName);spawn_direction = GetActorRotation().ForwardVector;offset_location = spawn_location + (spawn_direction * ForwardOffset);
SpawnActor(ProjectileClass, offset_location, GetActorRotation());}
Montage Notify Integration
Section titled “Montage Notify Integration”Control projectile spawn timing through animation notifies:
- Notify Name: “projectile_spawn”
- Timing Control: Spawn projectile at precise animation moment
- Animation Integration: Add notify to all projectile-based attack animations
Weapon-Specific Implementation
Section titled “Weapon-Specific Implementation”Magic Projectiles
Section titled “Magic Projectiles”- Socket: S_Right_Hand_Item
- Speed: 2000 units for medium-speed magical projectiles
- Scale: Standard sphere size
- VFX: Magical impact effects
Rifle Projectiles
Section titled “Rifle Projectiles”- Socket: Muzzle (pre-existing on gun mesh)
- Speed: 3000 units for high-velocity bullets
- Scale: Small bullet size (adjust X/Y/Z independently)
- Forward Offset: 5 units from muzzle
Bow Projectiles
Section titled “Bow Projectiles”- Socket: S_Arrow (custom socket on bow mesh)
- Speed: 3000 units for arrow velocity
- Scale: Elongated (X=5, Y=0.5, Z=0.5) for arrow appearance
- Trajectory: May include slight gravity for realistic arc
Grenade System
Section titled “Grenade System”Grenade Projectile Setup
Section titled “Grenade Projectile Setup”Special projectile configuration for area damage:
Grenade Properties
Section titled “Grenade Properties”- Custom Rotation: Enable custom rotation input for arc trajectory
- Gravity: Gravity scale 1 for realistic throwing arc
- Explosion: Area damage on impact
- Timer Detonation: Alternative to impact detonation
Grenade Throw Implementation
Section titled “Grenade Throw Implementation”- Launch Angle: X rotation 22.5 degrees for throwing arc
- Custom Rotation: Override normal forward direction
- Speed/Gravity Balance: Adjust for satisfying throw feel
Projectile Polish
Section titled “Projectile Polish”Visual Effects Integration
Section titled “Visual Effects Integration”- Impact VFX: Spawn particle effects on hit
- Trail Effects: Optional trail particles during flight
- Environmental Integration: Ensure landscape generates overlap events
Performance Optimization
Section titled “Performance Optimization”- Cleanup Timer: Destroy projectiles after set duration
- Collision Disable: Turn off collision after hit before destruction
- Visibility: Hide projectile mesh after impact while VFX plays
Team System Integration
Section titled “Team System Integration”Prepare projectile system for team-based games:
- Team Variable: Expose team assignment on spawn
- Friendly Fire: Prevent damage to same-team characters
- Owner Exclusion: Prevent self-damage from own projectiles
The projectile system provides flexible, reusable ranged combat mechanics that integrate smoothly with animation timing and visual effects while supporting multiple projectile types and behaviors.