Crosshair showing when hovering over interactable objects.

The mechanis may seem easy, but in the background it requires some work.

Ill try to explain

First I made function where I can build it up in without filling my screen to much, PlayerLookingAtInteractiveObject

I dont want to line trace to happen when the player is standing still, so the function PlayerLookingAtInteractiveObject is used in the player movement controls, like Mouse and WASD input.

Then I made a new function called LineScanInteractiveObjects, which does the actual line tracing.

The received results of the Linetrace are then used in a different function to DefinePlayerAction
As the traced actors have their own tags, I can use these tags to see what action can be performed with that object. In my example, I only have a lightswitch

In order to get the Widget to pop up and tell you that you can perform an action, I’ve made a Blueprint Library function that casts for a widget and then set the text variable. I’ve used a DataTable to store the texts in, as I’m way to lazy to hard code it. Using a DataTable, all you’ve to remember is the Row Name and what Text was there.

So now that we have LineTraced a object, found it has a tag, displayed a widget that you can perform an action, enabled input, now we just need to handle the players input to perform the action. Which is the easiest of all.