Bevy All-in-One Documentation

A powerful 3D/2.5D game controller plugin for Bevy Engine.


Project maintained by yaskhan Hosted on GitHub Pages — Theme by mattgraham

Interaction System

This document provides a complete, production-ready description of the Interaction System. It is written for designers, gameplay programmers, and technical artists who need a deep understanding of how interactions are detected, validated, presented, and dispatched across the game. All descriptions are system-focused and remain implementation-agnostic, while still reflecting the real data and behavior defined by the codebase.

Documentation Contents

Overview

The Interaction System orchestrates how players and AI-controlled entities discover, understand, and activate interactive objects. It merges short-range raycast detection, proximity-driven device lists, and context-aware UI prompts into a single operational flow. The system is intentionally modular, enabling game teams to use only lightweight components for simple interactions, or full device lists for complex in-world machinery. It also plays a bridging role between other subsystems, such as puzzles, inventory, dialog, and devices. By design, it is neutral to narrative content; it focuses on selection and dispatch, leaving actual effects to downstream systems.

Key characteristics include:

Design Goals

Terminology

High-Level Architecture

The Interaction System is composed of a plugin, components, resources, events, and systems. A single plugin wires the update order so detection feeds selection, selection feeds validation, and validation feeds processing. The architecture favors a data-driven flow where each stage consumes state produced by the previous stage.

Core architectural pillars:

The system also includes explicit hooks for specific downstream use cases:

Interaction Lifecycle

The lifecycle below describes the canonical flow for a player-initiated interaction. Each step is deterministic and repeatable, ensuring that UI and gameplay logic remain aligned.

  1. Sensor Update
    • The Interaction Detector updates on a configurable interval.
    • A raycast is emitted from the detector origin using the configured offset.
    • The closest hit is stored as the candidate interactable.
  2. Device Proximity Scan
    • The device list system evaluates nearby devices based on distance thresholds.
    • Devices are added or removed from the list using queue-based events.
  3. Selection
    • If the player has a device list, the closest valid device is selected.
    • If no device is selected, the raycast candidate becomes the active interactable.
  4. Range and State Validation
    • Interaction distance and cooldowns are evaluated.
    • Interactables can opt out dynamically via the can_interact flag.
  5. UI Update
    • The prompt displays the chosen target and interaction verb.
    • The prompt color reflects whether the target is in range.
    • When no target exists, the prompt is hidden.
  6. Input Consumption
    • Interaction input is detected directly or via buffered input.
    • On success, the buffered input is consumed to prevent duplicate activation.
  7. Interaction Execution
    • The interaction event is queued with source, target, and interaction type.
    • Device state toggles if the target is a usable device.
    • Secondary system events such as electronic device activation are queued.
  8. Cooldown Enforcement
    • The interactable cooldown timer begins if configured.
    • The interactable is temporarily locked until the cooldown expires.

Component Reference

This section documents all components in the Interaction System. Each component includes a purpose statement, configuration details, and practical use notes.

InteractionDetector

Purpose:

Interactable

Purpose:

UsingDevicesSystem

Purpose:

DeviceStringAction

Purpose:

InteractionPrompt

Purpose:

InteractionData

Purpose:

UsableDevice

Purpose:

Type Reference

InteractionType

Purpose:

DeviceInfo

Purpose:

Resource Reference

CurrentInteractable

Purpose:

InteractionDebugSettings

Purpose:

InteractionUIState

Purpose:

Event and Queue Reference

AddDeviceEvent

Purpose:

RemoveDeviceEvent

Purpose:

InteractionEvent

Purpose:

InteractionEventQueue

Purpose:

AddDeviceQueue and RemoveDeviceQueue

Purpose:

System Reference

This section describes each system in the Interaction plugin, its responsibilities, and its practical implications.

setup_interaction_ui

Responsibilities:

update_interaction_ui

Responsibilities:

validate_interactions

Responsibilities:

detect_interactables

Responsibilities:

process_interactions

Responsibilities:

debug_draw_interaction_rays

Responsibilities:

update_device_list

Responsibilities:

select_closest_device

Responsibilities:

detect_devices_in_proximity

Responsibilities:

Device Management Model

The device model exists to solve scenarios where multiple interactive devices are close together. Instead of letting the raycast select an arbitrary target, devices are tracked in a list and selected deterministically. The list uses proximity scanning and explicit add/remove events to ensure predictable selection.

Key behaviors:

Device selection flow:

Design implications:

UI and Prompt Behavior

The interaction prompt is the primary communication tool for interactions. Its state is derived directly from selection logic to maintain player trust.

Prompt composition rules:

Visual feedback rules:

Usability notes:

Input Integration

The Interaction System integrates with the shared input subsystem. It supports both immediate input and buffered input to ensure responsive interactions.

Input handling characteristics:

Design guidance:

Cross-System Integration

The Interaction System provides a central handshake between player input and other systems. It emits interaction events and exposes state that other subsystems can interpret.

Common integration patterns:

Integration guidelines:

Performance and Scaling

The Interaction System is lightweight but must be tuned for large scenes. Performance considerations:

Scaling recommendations:

Debugging and Visualization

Debug visualization is essential for diagnosing interaction issues. The debug system draws rays and hit points for each detector.

Recommended debug workflow:

Debug data to log:

Save and Serialization Notes

The Interaction System itself does not automatically persist state. However, several components have data worth saving for continuity.

Common persistence targets:

Serialization guidance:

Multiplayer and Networking Considerations

Multiplayer implementations should treat interaction selection as local and interaction execution as authoritative. Key considerations:

Design Patterns Catalog

The following catalog lists common interaction design patterns. Each pattern is described with its intent and implementation guidance.

Pattern 001: Simple Pickup

Intent:

Pattern 002: Contextual Use

Intent:

Pattern 003: Talk Trigger

Intent:

Pattern 004: Door Interaction

Intent:

Pattern 005: Terminal Activation

Intent:

Pattern 006: Puzzle Lever

Intent:

Pattern 007: Timed Switch

Intent:

Pattern 008: Multi-Step Device

Intent:

Pattern 009: Key-Locked Door

Intent:

Pattern 010: Quest Gated Use

Intent:

Pattern 011: Inspection Point

Intent:

Pattern 012: Loot Chest

Intent:

Pattern 013: Vehicle Entry

Intent:

Pattern 014: Seat Selection

Intent:

Pattern 015: Lift Control

Intent:

Pattern 016: Power Relay

Intent:

Pattern 017: Emergency Button

Intent:

Pattern 018: Alarm Toggle

Intent:

Pattern 019: Hidden Panel

Intent:

Pattern 020: Crafting Station

Intent:

Pattern 021: Simple Pickup

Intent:

Pattern 022: Contextual Use

Intent:

Pattern 023: Talk Trigger

Intent:

Pattern 024: Door Interaction

Intent:

Pattern 025: Terminal Activation

Intent:

Pattern 026: Puzzle Lever

Intent:

Pattern 027: Timed Switch

Intent:

Pattern 028: Multi-Step Device

Intent:

Pattern 029: Key-Locked Door

Intent:

Pattern 030: Quest Gated Use

Intent:

Pattern 031: Inspection Point

Intent:

Pattern 032: Loot Chest

Intent:

Pattern 033: Vehicle Entry

Intent:

Pattern 034: Seat Selection

Intent:

Pattern 035: Lift Control

Intent:

Pattern 036: Power Relay

Intent:

Pattern 037: Emergency Button

Intent:

Pattern 038: Alarm Toggle

Intent:

Pattern 039: Hidden Panel

Intent:

Pattern 040: Crafting Station

Intent:

Pattern 041: Simple Pickup

Intent:

Pattern 042: Contextual Use

Intent:

Pattern 043: Talk Trigger

Intent:

Pattern 044: Door Interaction

Intent:

Pattern 045: Terminal Activation

Intent:

Pattern 046: Puzzle Lever

Intent:

Pattern 047: Timed Switch

Intent:

Pattern 048: Multi-Step Device

Intent:

Pattern 049: Key-Locked Door

Intent:

Pattern 050: Quest Gated Use

Intent:

Pattern 051: Inspection Point

Intent:

Pattern 052: Loot Chest

Intent:

Pattern 053: Vehicle Entry

Intent:

Pattern 054: Seat Selection

Intent:

Pattern 055: Lift Control

Intent:

Pattern 056: Power Relay

Intent:

Pattern 057: Emergency Button

Intent:

Pattern 058: Alarm Toggle

Intent:

Pattern 059: Hidden Panel

Intent:

Pattern 060: Crafting Station

Intent:

Pattern 061: Simple Pickup

Intent:

Pattern 062: Contextual Use

Intent:

Pattern 063: Talk Trigger

Intent:

Pattern 064: Door Interaction

Intent:

Pattern 065: Terminal Activation

Intent:

Pattern 066: Puzzle Lever

Intent:

Pattern 067: Timed Switch

Intent:

Pattern 068: Multi-Step Device

Intent:

Pattern 069: Key-Locked Door

Intent:

Pattern 070: Quest Gated Use

Intent:

Pattern 071: Inspection Point

Intent:

Pattern 072: Loot Chest

Intent:

Pattern 073: Vehicle Entry

Intent:

Pattern 074: Seat Selection

Intent:

Pattern 075: Lift Control

Intent:

Pattern 076: Power Relay

Intent:

Pattern 077: Emergency Button

Intent:

Pattern 078: Alarm Toggle

Intent:

Pattern 079: Hidden Panel

Intent:

Pattern 080: Crafting Station

Intent:

Pattern 081: Simple Pickup

Intent:

Pattern 082: Contextual Use

Intent:

Pattern 083: Talk Trigger

Intent:

Pattern 084: Door Interaction

Intent:

Pattern 085: Terminal Activation

Intent:

Pattern 086: Puzzle Lever

Intent:

Pattern 087: Timed Switch

Intent:

Pattern 088: Multi-Step Device

Intent:

Pattern 089: Key-Locked Door

Intent:

Pattern 090: Quest Gated Use

Intent:

Pattern 091: Inspection Point

Intent:

Pattern 092: Loot Chest

Intent:

Pattern 093: Vehicle Entry

Intent:

Pattern 094: Seat Selection

Intent:

Pattern 095: Lift Control

Intent:

Pattern 096: Power Relay

Intent:

Pattern 097: Emergency Button

Intent:

Pattern 098: Alarm Toggle

Intent:

Pattern 099: Hidden Panel

Intent:

Pattern 100: Crafting Station

Intent:

Pattern 101: Simple Pickup

Intent:

Pattern 102: Contextual Use

Intent:

Pattern 103: Talk Trigger

Intent:

Pattern 104: Door Interaction

Intent:

Pattern 105: Terminal Activation

Intent:

Pattern 106: Puzzle Lever

Intent:

Pattern 107: Timed Switch

Intent:

Pattern 108: Multi-Step Device

Intent:

Pattern 109: Key-Locked Door

Intent:

Pattern 110: Quest Gated Use

Intent:

Pattern 111: Inspection Point

Intent:

Pattern 112: Loot Chest

Intent:

Pattern 113: Vehicle Entry

Intent:

Pattern 114: Seat Selection

Intent:

Pattern 115: Lift Control

Intent:

Pattern 116: Power Relay

Intent:

Pattern 117: Emergency Button

Intent:

Pattern 118: Alarm Toggle

Intent:

Pattern 119: Hidden Panel

Intent:

Pattern 120: Crafting Station

Intent:

Edge Case Catalog

This catalog enumerates interaction edge cases and suggested mitigations. Each entry is written as a scenario with a resolution approach.

Edge Case 001

Scenario:

Edge Case 002

Scenario:

Edge Case 003

Scenario:

Edge Case 004

Scenario:

Edge Case 005

Scenario:

Edge Case 006

Scenario:

Edge Case 007

Scenario:

Edge Case 008

Scenario:

Edge Case 009

Scenario:

Edge Case 010

Scenario:

Edge Case 011

Scenario:

Edge Case 012

Scenario:

Edge Case 013

Scenario:

Edge Case 014

Scenario:

Edge Case 015

Scenario:

Edge Case 016

Scenario:

Edge Case 017

Scenario:

Edge Case 018

Scenario:

Edge Case 019

Scenario:

Edge Case 020

Scenario:

Edge Case 021

Scenario:

Edge Case 022

Scenario:

Edge Case 023

Scenario:

Edge Case 024

Scenario:

Edge Case 025

Scenario:

Edge Case 026

Scenario:

Edge Case 027

Scenario:

Edge Case 028

Scenario:

Edge Case 029

Scenario:

Edge Case 030

Scenario:

Edge Case 031

Scenario:

Edge Case 032

Scenario:

Edge Case 033

Scenario:

Edge Case 034

Scenario:

Edge Case 035

Scenario:

Edge Case 036

Scenario:

Edge Case 037

Scenario:

Edge Case 038

Scenario:

Edge Case 039

Scenario:

Edge Case 040

Scenario:

Edge Case 041

Scenario:

Edge Case 042

Scenario:

Edge Case 043

Scenario:

Edge Case 044

Scenario:

Edge Case 045

Scenario:

Edge Case 046

Scenario:

Edge Case 047

Scenario:

Edge Case 048

Scenario:

Edge Case 049

Scenario:

Edge Case 050

Scenario:

Edge Case 051

Scenario:

Edge Case 052

Scenario:

Edge Case 053

Scenario:

Edge Case 054

Scenario:

Edge Case 055

Scenario:

Edge Case 056

Scenario:

Edge Case 057

Scenario:

Edge Case 058

Scenario:

Edge Case 059

Scenario:

Edge Case 060

Scenario:

Edge Case 061

Scenario:

Edge Case 062

Scenario:

Edge Case 063

Scenario:

Edge Case 064

Scenario:

Edge Case 065

Scenario:

Edge Case 066

Scenario:

Edge Case 067

Scenario:

Edge Case 068

Scenario:

Edge Case 069

Scenario:

Edge Case 070

Scenario:

Edge Case 071

Scenario:

Edge Case 072

Scenario:

Edge Case 073

Scenario:

Edge Case 074

Scenario:

Edge Case 075

Scenario:

Edge Case 076

Scenario:

Edge Case 077

Scenario:

Edge Case 078

Scenario:

Edge Case 079

Scenario:

Edge Case 080

Scenario:

Best Practices

Testing and QA Checklist

Interaction detection:

Device behavior:

Input behavior:

UI behavior:

State and cooldown:

Integration tests:

Troubleshooting

Problem: The prompt never appears.

Problem: The prompt appears but interaction does nothing.

Problem: Interactions trigger multiple times.

Problem: Device interactions target the wrong object.

Problem: UsableDevice does not toggle state.

Future Extensions

The Interaction System is designed to be extensible. Potential additions include:

Closing Notes

This document intentionally focuses on system behavior, data models, and operational guidance. It should be used as the primary reference when designing, implementing, or debugging interactions. For deeper integration with other systems, consult the documentation for those subsystems and apply the integration guidance described above.