A performant, server-validated C++ interaction system for Unreal Engine 5. Designed for decoupled logic, easy Blueprint extension, and safe actor lifecycle management.
Demo_Map.mp4
- Optimized Tracing: Uses
FTimerHandleinstead ofEvent Tickfor local controller line tracing. - Network Authority: Client-side prediction with server-side distance validation (
ServerTryInteract) prevents interaction exploits. - Safe Lifecycle Handling: Automatically nullifies interaction pointers if the target actor is destroyed (e.g., consumable pickups).
- Blueprint Ready: Interaction logic and UI text are exposed via
BlueprintNativeEvent, allowing non-programmers to create interactable objects.
Replication_review.mp4
The project includes a ready-to-play map demonstrating three core interaction paradigms:
- C++ Implementation (Door): A C++ actor using a
USceneComponenthinge to manage open/close state. - Blueprint Implementation (Light): A fully Blueprint-implemented actor demonstrating interface inheritance without C++ logic.
- Actor Lifecycle (Pickup): A C++ item that broadcasts its data and calls
Destroy()upon interaction, showcasing safe pointer cleanup.
The interaction system is fully decoupled and exposed to Blueprints via IInteractableInterface. Designers and non-programmers can easily create new interactable objects and custom logic without writing a single line of C++ code.
For example, here is the complete implementation of BP_LightSwitch using Event Interact:
UInteractorComponent: The brain of the system. Attach to any Pawn/Character. Configurable trace distance (default:450.f) and timer intervals.IInteractableInterface: Requires targets to implementInteract()andGetInteractText() const.
- Clone the repository and open
.uproject. - Ensure your project uses the
InteractableCollision Channel (default response: Ignore, block on target actors). - Open the included Demo Map to test BP and C++ interactable examples.