Skip to content
Pablo Rodriguez

Trap Knockback System

Transform the basic statistic changer into a comprehensive trap and environmental hazard system that supports multiple effect types and customizable behaviors.

Upgrade the statistic modifier with improved components:

  • Static Mesh Appearance: Root component for visual representation
  • Box Collision: Trigger volume for trap activation
  • Static Mesh Variable: Instance-editable mesh selection
  • Construction Script: Apply selected mesh to appearance component
  • Trigger Collision: Custom collision settings
  • Box Collision: Set to overlap pawn only
  • Static Mesh: No collision, no overlap events (visual only)
  • Hidden Sphere: Remove or hide original sphere component

Create enumeration for different trap effects:

  • Health: Damage or healing effect
  • Knockback: Physical displacement effect
  • Jump Pad: Upward/directional launching

Allow multiple simultaneous effects per trap:

// Multi-Effect Trap Implementation
OnTrapActivation(TriggeringActor) {
ForEach(effect_type in Effects_Array) {
switch(effect_type) {
case Health:
Interface_Health_Modify(TriggeringActor, Math_Operation, Health_Amount);
break;
case Knockback:
CalculateKnockbackDirection(TriggeringActor);
Interface_Knockback(TriggeringActor, Knockback_Location, Knockback_Power);
break;
case JumpPad:
LaunchCharacterInDirection(TriggeringActor, Custom_Launch_Direction);
break;
}
}
}

Create master character interface for knockback effects:

  • Location Input: Vector position for knockback origin
  • Power Input: Float value for knockback strength
  • Implementation: Use Launch Character node with calculated direction
// Knockback Direction Calculation
Interface_Knockback(KnockbackLocation, Power) {
character_location = GetActorLocation();
look_at_rotation = FindLookAtRotation(KnockbackLocation, character_location);
forward_vector = look_at_rotation.ForwardVector;
launch_vector = forward_vector * Power;
LaunchCharacter(launch_vector, true, true); // Override X, Y, Z
}

This system ensures characters are always knocked back from trap location regardless of approach angle.

Transform knockback system into directional jump pads:

  • Knockback_Custom Boolean: Enable custom direction mode
  • Knockback_Custom_Location Vector: Specific launch direction
  • Instance Editable: Allow per-trap customization
// Jump Pad Custom Direction
if (Knockback_Custom) {
launch_direction = Knockback_Custom_Location;
} else {
launch_direction = CalculateKnockbackFromTrapLocation();
}
LaunchCharacter(launch_direction, true, true);

Different jump pad configurations:

  • Custom Direction: (X=0, Y=0, Z=1200)
  • Use Case: Vertical platforming challenges
  • Feel: Straight upward launch
  • Custom Direction: (X=0, Y=-3000, Z=800)
  • Use Case: Traversal across gaps or level shortcuts
  • Balance: Negative Y for forward movement, positive Z for arc

Configure traps for harm:

  • Static Mesh: Spike trap, fire hazard, electrical danger
  • Effects Array: Health effect only
  • Damage Amount: 250 for significant but not instantly lethal
  • Knockback Power: 800 for impact feedback

Configure for displacement without damage:

  • Effects Array: Knockback only
  • Knockback Power: 1200-1500 for strong displacement
  • Use Cases: Environmental hazards, puzzle elements

Multi-effect environmental hazards:

  • Effects Array: Health + Knockback
  • Balanced Values: Lower damage with moderate knockback
  • Strategic Placement: Create risk/reward positioning decisions

Position traps for maximum gameplay impact:

  • Narrow Passages: Force careful navigation
  • Combat Areas: Add environmental danger to fights
  • Puzzle Integration: Use as puzzle elements or barriers
  • Jump Pad Networks: Create traversal shortcuts and alternate routes

Ensure traps are properly telegraphed:

  • Appropriate Meshes: Spikes look dangerous, pads look helpful
  • Material Choices: Bright colors for jump pads, dark/warning colors for damage
  • Consistent Language: Similar trap types use similar visual themes

Create child blueprints for common configurations:

  • Default Mesh: Spike trap asset
  • Default Effects: Health (damage) + Knockback
  • Preset Values: Balanced damage and knockback
  • Default Mesh: Launch pad or magical circle
  • Default Effects: Jump Pad with vertical boost
  • Preset Direction: Pure upward launch
  • Default Mesh: Explosive or energy device
  • Default Effects: Pure knockback, no damage
  • High Power: Strong displacement for environmental puzzles

The trap and knockback system adds dynamic environmental interaction and creates opportunities for both hazards and traversal mechanics while maintaining flexible, reusable code architecture.