Interaction: Traces + Blueprint Interface โ
What/Why: Simple, scalable interaction using a trace and a Blueprint Interface. Keeps props reusable and player logic thin.
Prereqs
- Collision channel for interactables (optional); or use Object Types (WorldDynamic) and tags
- Input:
IA_Interact (Bool)bound inIMC_Gameplay
Steps
- Create the interface
- Create
BPI_Interactablewith functions:Interact(Instigator: Actor)โ called on serverHighlight(bEnable: bool)โ client-side feedbackGetPrompt() -> Textโ UI hint
- Build an Interaction Component (Actor Component)
BP_InteractionTraceComponent(attach to Pawn):- Variables: TraceDistance (float = 300), TraceRadius (float = 8), bDrawDebug (bool)
- Function
FindBestInteractable():- LineTrace or SphereTrace from camera forward; ignore owner; filter by
Does Implement Interface BPI_Interactable - Track CurrentTarget; if changed, call
Highlighton new/old
- LineTrace or SphereTrace from camera forward; ignore owner; filter by
- Function
TryInteract():- If CurrentTarget valid โ run
Server_Interact(CurrentTarget)RPC on owning client
- If CurrentTarget valid โ run
- Wire input to interaction
- In Pawn/Controller: bind
IA_Interact (Triggered)โ callInteractionTraceComponent.TryInteract() - Call
FindBestInteractable()on a low-frequency timer (e.g., 10โ20 Hz) or when look direction changes (advanced)
- Implement the prop side
- Any Actor can implement
BPI_Interactable:Interactโ perform action (open door, pick up) on serverHighlightโ enable outline/indicator locallyGetPromptโ return a short text for UI
Data
- Optional
DA_InteractConfigfor trace distance, prompt style, outline color - Use Gameplay Tags on interactables for categories (Interact.Type.Door, Item, Terminal)
Networking
- Interact call is server-authoritative: Owning client โ
Server_Interact(Target)โ validate โ execute - Highlight stays client-side; donโt replicate unless needed
- Replicate state changes (doors open, items gone) via normal replicated vars/Multicast
Performance
- Avoid per-tick heavy traces; use a timer at ~0.05โ0.1s or event-driven updates
- Prefer LineTraceForObjects over complex channels; keep collision simple
- Cull highlight FX in distance; avoid material parameter spam every frame
Testing
- Add a debug print of
GetPrompt()when a target is available - Toggle bDrawDebug to see traces; verify highlight swaps when looking around
- Press Interact once; action triggers once on server (no client-only side effects)
Suggested prompts โ
- โUE 5.6 Blueprints only. Create
BPI_InteractablewithInteract(Instigator),Highlight(bool), andGetPrompt(). Show a player component that traces and calls these functions.โ - โWhat timer rate is reasonable for interaction traces and how do I avoid spamming highlight?โ
- โShow how to make
Interactserver-authoritative via RPC from the owning client.โ - โProvide a quick checklist for collision and trace filters when interactions donโt detect.โ
Prompts for this example
- โGiven my
BP_InteractionTraceComponent, write the nodes to do a line trace from the camera and pick the nearest actor that implementsBPI_Interactable.โ - โShow the RPC wiring for
Server_Interact(Target)so Interact runs only on the server.โ