Build a simple interaction system in Unreal
- farcaptain
- Mar 27, 2023
- 1 min read
I'm currently developing an interactive system for my third-person game in UE4. Initially, I set up the system using popular methods such as collision detection and line tracing.
However, I want to enhance the player's experience by providing clearer feedback, such as "you can pick this up." My goal is to highlight interactable objects when the player is near and to focus on the one with the smallest angle relative to the camera, as the player can only interact with one object at a time (due to having only one interaction button). By doing so, we can subtly guide the player towards the interactable object, and when they are genuinely looking at it, the option to interact will be displayed.
One of my sources of inspiration for this approach - the Hitman game series.
To achieve this, we need to move away from relying solely on raycasting, as it would require constant ray casting to detect objects and display the outline and widget. Instead, we can use collision detection as a more efficient way to determine if an object is within range. Once we have a list of objects in range, we can identify the one with the smallest angle. Additionally, we must ensure that the object is still within the viewport before allowing interaction.
Now, this looks like:
Looks quite promising!
Comments