Weapon Interaction System
Weapon Interaction System
Section titled “Weapon Interaction System”Interaction Framework
Section titled “Interaction Framework”Create a flexible interaction system that handles weapon pickup, environmental interactions, and world navigation.
Basic Interact Setup
Section titled “Basic Interact Setup”Enhanced Input Configuration
Section titled “Enhanced Input Configuration”Set up interaction keybind:
- Input Action: IA_Interact
- Keybind: F key
- Input Mapping: Add to IMC_Default context
- Trigger: Started trigger for immediate response
Interact Trace System
Section titled “Interact Trace System”Implement sphere trace for interaction detection:
// Player Interaction TraceOnInteractPressed() {start_location = GetActorLocation() + (ForwardVector * 100);end_location = GetActorLocation() + (ForwardVector * 150);
SphereTraceByChannel(start_location, end_location, 80, 'Interact');
if (hit_result.IsValid()) {hit_result.Actor.Interface_Interact(Self);}}
Custom Collision Channel
Section titled “Custom Collision Channel”Create dedicated interaction collision channel:
- Project Settings > Collision: Add new trace channel “Interact”
- Default Response: Ignore
- Interactable Objects: Set to Block on Interact channel
Weapon Select Actor
Section titled “Weapon Select Actor”Weapon Pickup System
Section titled “Weapon Pickup System”Create actors for weapon selection and pickup:
Actor Components
Section titled “Actor Components”- Arrow Component: Root for positioning control
- Skeletal Mesh: Display weapon appearance
- Box Collision: Interaction detection volume
- Rotating Movement: Visual appeal
Weapon Type System
Section titled “Weapon Type System”- Animation Stance Enum Variable: Determines weapon type
- Instance Editable: Allow level designers to set weapon type
- Construction Script: Update skeletal mesh based on weapon type
Weapon Selection Function
Section titled “Weapon Selection Function”// Weapon Type SelectionF_Set_Weapon_Type() {switch(Weapon_Type) {case Shield: SetSkeletalMesh(ShieldAsset); break;case TwoHanded: SetSkeletalMesh(TwoHandedAsset); break;case Rifle: SetSkeletalMesh(RifleAsset); break;case Bow: SetSkeletalMesh(BowAsset); break;case Stealth: SetSkeletalMesh(DaggerAsset); break;case Unarmed: SetSkeletalMesh(BubbleWandAsset); break;}}
Weapon Equip Interface
Section titled “Weapon Equip Interface”Create communication between weapon pickups and player:
- Player Interface Function: Interface_Equip_Weapon
- Weapon Type Parameter: Pass selected weapon type to player
- Animation Stance Update: Change player’s current weapon stance
Teleporter System
Section titled “Teleporter System”Multi-Purpose Teleporter Actor
Section titled “Multi-Purpose Teleporter Actor”Create versatile teleporter for doors, ladders, and teleportation:
Core Components
Section titled “Core Components”- Arrow Component: Root component for positioning
- Static Mesh: Visual representation (door, ladder, teleport pad)
- Box Collision: Interaction detection
- Sphere Components: Teleport destination markers (Sphere_A, Sphere_B)
Teleportation Logic
Section titled “Teleportation Logic”// Smart Teleportation SystemOnInteract(PlayerActor) {player_location = PlayerActor.GetActorLocation();distance_to_sphere_A = Distance(player_location, Sphere_A.Location);distance_to_sphere_B = Distance(player_location, Sphere_B.Location);
if (distance_to_sphere_A > distance_to_sphere_B) {PlayerActor.SetActorLocation(Sphere_A.Location);} else {PlayerActor.SetActorLocation(Sphere_B.Location);}}
Teleporter Variants
Section titled “Teleporter Variants”Create child blueprints for specific use cases:
Door Actor
Section titled “Door Actor”- Static Mesh: Door asset
- Sphere Placement: One on each side of door
- Use Case: Room transitions, building entrances
Ladder Actor
Section titled “Ladder Actor”- Static Mesh: Ladder asset
- Sphere Placement: Top and bottom of ladder
- Use Case: Vertical level transitions
Teleporter Pad
Section titled “Teleporter Pad”- Static Mesh: Magical/technological pad
- Sphere Placement: One nearby, one at distant location
- Use Case: Long-distance transportation
Environmental Interaction Actors
Section titled “Environmental Interaction Actors”Trap System Enhancement
Section titled “Trap System Enhancement”Expand statistic changer into comprehensive trap system:
Multi-Effect Trap
Section titled “Multi-Effect Trap”- Effects Array: Support multiple simultaneous effects
- Effect Types: Health damage, knockback, jump pad boost
- Customizable Power: Adjustable knockback strength, damage amounts
Knockback Implementation
Section titled “Knockback Implementation”// Knockback Trap EffectOnTrapTrigger(PlayerActor) {trap_location = GetActorLocation();player_location = PlayerActor.GetActorLocation();
knockback_direction = FindLookAtRotation(trap_location, player_location);launch_vector = knockback_direction.ForwardVector * knockback_power;
PlayerActor.Interface_Knockback(launch_vector, knockback_power);}
Jump Pad System
Section titled “Jump Pad System”Transform knockback traps into jump pads:
- Custom Direction: Override automatic direction calculation
- Launch Vector: Set specific X/Y/Z launch values
- Use Cases: Vertical boost, directional launching, traversal assistance
Interaction Polish
Section titled “Interaction Polish”Visual Feedback
Section titled “Visual Feedback”Enhance interaction system with clear feedback:
- Interaction Prompts: UI indicators when objects can be interacted with
- Highlight Effects: Visual emphasis on interactable objects
- Audio Feedback: Sound effects for successful interactions
Range and Precision
Section titled “Range and Precision”Fine-tune interaction detection:
- Sphere Radius: 80 units provides good interaction range without being overly generous
- Forward Offset: Start trace ahead of player to prevent wall-clipping issues
- Trace Length: 50-unit trace length for responsive but not excessive range
Object Organization
Section titled “Object Organization”Organize interaction objects for level design efficiency:
- Child Actor System: Create variations without code duplication
- Instance Variables: Allow customization per-instance
- Template System: Standardized interaction objects for consistent behavior
The weapon interaction system provides the foundation for player progression, world navigation, and environmental puzzle-solving while maintaining clean, reusable code architecture.