How would I make text appear above an actor

I’m trying to create a blueprint that when the player looks at an actor with itemData, text will appear above that actor. I already know how to set it, I just don’t know how I would make that text appear when your looking at it and disappear in the player in not

you can add a TextRender to your actor BP and by tracing a ray from your player or its camera and get the name of the hit actor toggle that text’s visibility

The thing you’re searching for is called RayTracing and is something that is used in pretty much every game engine out there.

What it does is it draws an imaginary line between two points and provides you with whatever it finds in between.

This is at the very core of the collision system meaning everything you set up with collision can be found by a trace.

Here is a documentation page about using Traces in Blueprint:

What you gonna wanna do is set it up very similar to that documentation on “Event Tick” in your Player Character or Player Controller and trace each tick forwards from your camera (as shown in the documentation).

To make development easy you should use an interface for the next step.

Simply add a function with a names like “Show Text” in your interface and add it to whatever has the text.

You can take the “Hit Actor” from your “Hit Result” that you got from the trace and call your “ShowText” function.

If the actor implements the interface it will try to call that function. Otherwise absolutely nothing happens which is exactly the intended behavior! It allows you to simply not care what you’re looking at! Either it works or it doesn’t. No errors. No warnings.

In your actor that has the text in the event graph search for “Event Show Text”. Make your text visible and right afterwards add a retriggerable delay of something along the lines of 1 second.

Now each tick (by default each frame) you look at something that can show text, it will make that text visible. After one second of not looking at it, the text will disappear!

Voila! You’re done!

Traces and Interfaces are truly magical things that help a TON when working on a game! Have fun playing with those new pieces of information you learned about!