Core Concepts

Understanding how the OwnInteract system works.


Architecture

The system uses a component-based architecture with two main components:

Player/Character
└─ InteractionComponent (Detector)
    ↓ Detects & Communicates With
Interactable Object
└─ InteractableComponent (Receiver)
    └─ WidgetComponent (UI Display)

Interaction Flow

Understanding the complete lifecycle of an interaction:

1. DETECTION
   Player's InteractionComponent checks for objects
   └─ Uses selected Detection Method (Line/Sphere/Overlap/Cone)

2. FOCUS
   Object found and passes all filters
   ├─ OnInteractionFocused called on object
   ├─ Widget becomes visible
   └─ OnInteractableFocused event fired

3. INPUT
   Player presses interaction key
   └─ StartInteraction() called

4. VALIDATION
   System checks if interaction is allowed
   ├─ Is object enabled?
   ├─ Not on cooldown?
   ├─ Player in range? (server check)
   └─ CanInteract returns true?

5. EXECUTION
   OnInteract event triggered
   └─ Your custom logic runs

6. UNFOCUS
   Player looks away
   ├─ OnInteractionUnfocused called
   └─ Widget disappears

Interaction Types

Instant

Behavior: Triggers immediately when input is pressed

Use Cases:

  • Open/close doors
  • Pick up items
  • Press buttons
  • Activate switches

Events:

  • OnInteract - Fired once on press

Example:

Event OnInteract
└─ Open Door

Hold

Behavior: Player must hold input for specified duration

Use Cases:

  • Lockpicking
  • Hacking terminals
  • Charging abilities
  • Mining/harvesting

Settings:

  • HoldDuration - Time in seconds (e.g., 2.0)

Events:

  • OnInteractionHoldStarted - Hold begins
  • OnInteractionHoldProgress - Updated every frame with progress (0.0 - 1.0)
  • OnInteractionHoldCompleted - Successfully held for full duration
  • OnInteractionHoldCancelled - Released early

Example:

Event OnHoldStarted
└─ Play Sound (Lockpick Start)

Event OnHoldProgress (Progress: 0.0 - 1.0)
└─ Update Progress Bar

Event OnHoldCompleted
└─ Unlock Door

Progress Tracking: The Progress parameter goes from 0.0 (just started) to 1.0 (complete). Use this to update progress bars, sounds, or visual effects.


Toggle

Behavior: Switches between on/off states

Use Cases:

  • Power generators
  • Light switches
  • Activation mechanisms
  • Machine on/off

Events:

  • OnInteract - Fired on each toggle

Example:

Event OnInteract
├─ Flip Boolean (bIsPowered)
└─ Branch: Is Powered?
   ├─ True → Turn On
   └─ False → Turn Off

State Management: You manage the state yourself using a boolean variable. The interaction just toggles - you decide what that means.


Detection Methods

Line Trace

  • Single ray from camera
  • Best for: FPS, precision targeting
  • Performance: Excellent

Sphere Trace

  • “Thick” swept sphere
  • Best for: Third-person, controllers
  • Performance: Good

Overlap

  • Radius around player
  • Best for: Adventure, proximity-based
  • Performance: Fair

Cone Detection

  • Distance + Angle combination
  • Best for: VR, tactical, wide areas
  • Performance: Good

Filtering Systems

Tag Filtering

Filter by Actor Tags

Required Tags: ["Interactable", "Item"]
Ignored Tags: ["Locked", "Disabled"]

Angle Filtering

Only objects in camera view

Max Detection Angle: 45°

Distance Filtering

Objects within range

Min: 100cm
Max: 500cm

Priority System

Choose best object when multiple overlap

NPC: Priority 10
Item: Priority 0

Components

InteractionComponent (Player)

Purpose: Detects and interacts with objects

Key Responsibilities:

  • Runs detection checks at intervals
  • Filters detected objects
  • Manages focused object
  • Sends interaction commands to server
  • Shows/hides widgets

InteractableComponent (Objects)

Purpose: Makes objects interactable

Key Responsibilities:

  • Stores interaction data
  • Responds to focus/unfocus
  • Handles interaction execution
  • Manages cooldowns
  • Controls widget visibility

Widget System

World-Space Widgets appear at the object’s location, not on screen.

Flow:

1. Object focused
   └─ InteractableComponent shows WidgetComponent
      └─ Widget receives InteractionData
         └─ Updates display (action name, etc.)

2. Object unfocused
   └─ InteractableComponent hides WidgetComponent

Key Points:

  • Widget must inherit from InteractionWidget C++ class
  • Widget Component must be in World Space
  • Widget Component starts Hidden
  • Each object can have its own widget

Multiplayer

Server Authority: All interactions validated by server

Flow:

1. Client presses "E"
   └─ Client calls StartInteraction()

2. RPC sent to Server
   └─ ServerStartInteraction()

3. Server Validates
   ├─ Distance check ✓
   ├─ Cooldown check ✓
   ├─ CanInteract check ✓
   └─ All pass → Execute

4. Server Executes
   ├─ OnInteract fires
   └─ State replicates to clients

Anti-Cheat:

  • Distance validated on server
  • Cooldowns enforced server-side
  • Client can’t bypass restrictions

Best Practices

Performance

DO:

  • Use appropriate Detection Interval (0.1 recommended)
  • Disable Debug in shipping builds
  • Use Distance Filtering for large worlds
  • Use Tag Filtering to reduce checks

DON’T:

  • Use very low Detection Interval (< 0.05) unless needed
  • Leave Debug enabled in builds
  • Put InteractionComponent on many actors (only player!)

Design

DO:

  • Use clear, descriptive InteractionNames (“Open Door” not “Interact”)
  • Set appropriate Hold Durations (1-3 seconds typical)
  • Use Priority for important objects (NPCs > Items)
  • Test with different Detection Methods

DON’T:

  • Make Hold Durations too long (> 5 seconds frustrating)
  • Forget to set collision on objects
  • Use same widget for everything (vary for visual interest)

Multiplayer

DO:

  • Trust the server validation
  • Use Replicated variables for state
  • Test with simulated lag
  • Implement visual feedback for all clients

DON’T:

  • Try to bypass server authority
  • Run important logic only on client
  • Forget about network latency in design

Common Patterns

Conditional Interaction

Event OnInteract
├─ Branch: Has Key?
│  ├─ True → Open Door
│  └─ False → Show Message "Locked"

One-Time Use

InteractableComponent:
└─ bIsReusable = False

Cooldown-Based

InteractionData:
└─ Cooldown = 5.0 (seconds)

Interaction Chains

// Step 1
Event OnInteract (Lever)
└─ Enable Next Object (Button)

// Step 2
Event OnInteract (Button)
└─ Complete Puzzle

Next Steps

Now that you understand the concepts:


← Getting Started | Back to Index | Troubleshooting →