Crosshair showing when hovering over interactable objects.

Hey. I’m trying to make a system, that will let the player interact with certain objects. The interaction itself works but i need a way to tell the player which objects he can interact with. I made it so that when the player hovers over something interactable a simple dot appears. The issue is, once this crosshair appears it never goes away.

Interaction is based on linetrace inside character blueprint.

It works all the time, checks if it hits anything and if it does it calls a function in interaction blueprint interface.

The interface is simple, it uses only 2 functions.

The switch blueprint uses this interface to toggle light visibility.

And here is my HUD.

Nothing I tried works :confused:

Ok, i found a sollution. The thing is the “Draw Croshair?” variable inside HUD blueprint was set inside switch blueprint. But when i was looking away from it there was no way of making it switch the variable to false.

HUD stays the same i just removed the “Interaction Possible?” function from interface and switch blueprints.
New character blueprint looks like this:

Now the line trace checks if it hits anything and if the object hit uses the correct interface. If both of these values are true it tells my HUD to draw a crosshair.

Hello friend, I’ve been trying to make something like you were trying to make. I actually made a different way but it works only one interactive mesh, so i decided to follow your way. But I’m kinda confused with your blueprints. What did you change, what did you switch?

If you can show me the blueprints, functions and other stuff that would be awesome. Thanks!

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.

Continuation… Couldnt add more screens.

In the playerPawn

The CustomEvent or Function to PerformAction can contain what ever you want the player to do.
In my case I’ve done this

You should be able to get started with this, good luck!

Wow, thanks for posting I’ve been scouring the web for this explanation. Would be great to see step by step in a tutorial, however I will be giving this ago shortly.