How to get interaction icons in First Person game?

Hi,

I’m quite new to UE4 Blueprints but loving them so far.

I’m creating a first person adventure game and have got the character to interact with objects in the game - you have to be within their collision box and then you left-click to raycast into them. If the collision is true then the interaction happens.

This is great, but I need a visual indicator for the player to know they can interact with this object.

Ideally I would like something like the icons that appear in “Layers of fear”:

This should appear attached to the interactive object, and only when the player is both looking right at it and is nearby (in its collision box). I have everything set up, just not sure how to make this icon appear.

Can anyone help? :slight_smile:

I hope someone help you to make this tutorial , as i know this will work with line trace .
you will find tutorial with line trace in youtube , search and you will find it

How to set up the icons depends a bit on how your objects are set up. Do all of your interactable objects have something in common with each other? Like - are all the interactable objects children of the same class? Do you use a blueprint interface with them?

But in general the idea would be to do a line trace from the player’s camera (out some X distance along the camera forward vector), break the hit result if it hits something, check whether the object that was hit is one of your interactable objects (either by class or interface use or something that they all have in common.). If it is, then change a texture variable in your HUD blueprint that draws the texture in the middle of the screen. If it’s not the correct option or your trace hits nothing at all, you change the HUD texture back into your default crosshair or null.

As an additional feature, if you want the objects to have different interaction icons, you could add a texture variable to your item itself and have your player blueprint cast to the object and get the texture to then pass into the HUD texture variable. Then you can make your item’s texture variable public and change it on each instance of the object if you want.