1---2name: ue5-world-interaction3description: UE5.6/UE5.7 world interaction systems for pickups, spawners, overlap/trace checks, and visual feedback. Use when requests involve interactive world actors, spawn logic, pickup behavior, interaction radius checks, success/failure feedback, and actor lifecycle control.4---56# Quick Start7- Define interaction model: overlap-driven, trace-driven, or explicit use key.8- Define actor set: pickup actor, optional spawner, optional visual mapping data asset.9- Output runtime state transitions from spawn to interaction resolution.1011# UE5.7 API Anchors12- Detection anchors:13 - `USphereComponent`, `UBoxComponent`14 - `UPrimitiveComponent::OnComponentBeginOverlap`15 - `UPrimitiveComponent::OnComponentEndOverlap`16 - `FHitResult`17- Trace anchors:18 - `UWorld::LineTraceSingleByChannel(...)`19 - `UWorld::SweepSingleByChannel(...)`20 - `UKismetSystemLibrary::SphereTraceSingle(...)`21- Lifecycle anchors:22 - `AActor::SetActorHiddenInGame(...)`23 - `AActor::SetActorEnableCollision(...)`24 - `AActor::Destroy(...)`25 - `AActor::SetActorTickEnabled(...)`26- Networking anchors:27 - server authority validation for interaction success28 - replicated result state for client feedback2930# Interaction Stage Contract31- Every interaction feature must define:32 - Detection source (overlap/trace/use-key)33 - Eligibility checks (distance, tags, inventory/capacity, authority)34 - Success and failure result payloads35 - Feedback path (VFX/SFX/UI)36 - Post-interaction lifecycle policy (destroy/disable/cooldown/respawn)37- If any item is missing, interaction behavior is underspecified.3839# Workflow40## 1) Actor and Component Setup41- Build root + collision + visual components with explicit collision channels.42- Define default states (`active`, `cooldown`, `consumed`) and replication needs.43- Keep collision shape and bounds aligned with intended interaction distance.4445## 2) Detection Path46- Overlap model: bind begin/end overlap delegates on collision component.47- Trace model: run line/sphere traces on input request and validate hit actor/component.48- Keep detection deterministic by explicit channels/profiles.4950## 3) Eligibility and Authority51- Validate target state, range, actor validity, and gameplay conditions.52- In multiplayer, validate success on server before mutating shared state.53- Return structured failure reason on rejection.5455## 4) Resolve Interaction56- On success: apply effect (grant item, trigger state change, start cooldown).57- On failure: keep state stable and emit reason-specific feedback.58- Prevent re-entrant execution during in-progress resolution.5960## 5) Feedback Path61- Emit VFX/SFX/UI feedback for both success and failure paths.62- Separate cosmetic-only effects from authoritative gameplay mutations.63- Keep feedback idempotent for repeated client updates.6465## 6) Lifecycle and Cleanup66- Choose lifecycle explicitly: destroy, hide+disable collision, or reuse via respawn timer.67- If spawner exists, track spawned instances and cleanup on reset/despawn.68- Disable tick for dormant interaction actors when not needed.6970# Constraints71- Keep interaction validation server-authoritative in multiplayer.72- Ensure collision channels and trace responses are explicit.73- Keep spawner randomization deterministic when reproducibility is needed.74- Avoid hidden side effects in `Tick` without clear need.75- Do not destroy actors before broadcasting required success/failure feedback.76- Keep overlap and trace paths functionally equivalent when both are enabled.7778# Failure Handling79- Symptom: overlap never triggers.80 - Locate: collision enabled state, overlap flags, collision channel responses.81 - Fix: enable overlap generation, set proper channel responses, verify component bounds.82- Symptom: trace path misses obvious targets.83 - Locate: trace channel/profile and ignore actor list.84 - Fix: align trace channel/profile and reduce self/owner ignore misuse.85- Symptom: interaction triggers multiple times.86 - Locate: missing in-progress guard and duplicated delegate bindings.87 - Fix: add state guard and ensure single bind per component.88- Symptom: client sees success but server rejects.89 - Locate: authority checks and RPC validation path.90 - Fix: move final validation to server and replicate authoritative result.91- Symptom: consumed pickup remains interactable.92 - Locate: lifecycle state and collision disable logic.93 - Fix: disable collision/interaction immediately after confirmed success.94- Symptom: spawned interactables leak over time.95 - Locate: spawner bookkeeping and reset cleanup path.96 - Fix: track spawned instances and destroy/disable stale instances on respawn cycle.97- Symptom: frame spikes near dense interaction areas.98 - Locate: per-frame trace/overlap workload and unnecessary ticking.99 - Fix: reduce polling frequency, gate traces by input/distance, disable idle tick.100101# Interaction Authority Ops102- Use server-validated interaction resolution for shared gameplay effects.103- Use client-side prediction only for cosmetic feedback when acceptable.104- Replicate result state, not raw input spam.105- Keep cooldown/timer ownership on authority side for deterministic multiplayer behavior.106107# UE5.6 / UE5.7 Compatibility Notes108- Overlap, trace, and actor lifecycle APIs listed above are stable across UE5.6 and UE5.7.109- Prefer explicit collision profile/channel configuration in both versions.110111# Escalation112- Escalate when design requires persistent world state synchronization across sessions.113- Escalate when system must integrate with GAS ability targeting rules.