need help with a "look at" event bluepring plz

Hey all - before I start I just want to let you know that I’m still pretty newbie in unreal so dumbing down your answers would be super appreciated :slight_smile:

I’m building an architectural walkthrough in unreal and I want to add some extra features to it
Basically I want to be able to change the colors of certain elements by looking at them an showing an text command

So let’s say I walk up to the kitchen cabinets - when I look at them I would like a text to appear that says something like “press E” and when that key is pressed it changes the color and cycles through a list of materials everytime it’s pressed

I feel like I have a lot of the pieces that I need but I can’t figure out how to bring them all together

I started with this
https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/UseRaycasts/Blueprints/index.html

I experimented with box collisions within the blueprint and used OnComponentBeginOverlap and the matching EndOverlap to control the text appearing within a certain distance
I used a multigate to cycle between the materials

It’s bringing all of them together that’s causing me problems

Any help would be awesome thank you!

Is your trace working correctly?
If so I think an Interface would work well for this, though it would depend on how you have your interactive objects set up.

Right click in the content browser and make a new interface, Blueprints>Blueprint Interface.
Call it, as an example, ObjectInterfaces. Make an interface in this one called ObjectUsed.

I presume you are doing the trace in your pawn, so in your pawn blueprint, click Class Settings on the toolbar, and under Interfaces add your interface:
XOERTMZ.png

You’ll have two separate traces, one for when an object is “used” (clicking E), and another for checking if an object is hovered.

Below is the trace for when an object is used. Essentially it just traces, gets the actor, and you call the interface on the object. You can do it this way, because calling an interface on an actor that does not implement it will fail silently and not cause any problems.

Then, in your interactive object, you also go to class settings and add the interface. Once it is implemented in the object, you can right click in the event graph and and an event for ObjectUsed.
This is where you add whatever you want to do when a user uses an object while looking at it:
64yDYEt.png

Then for the hover message. You do the same trace again, only this time you call it on Tick. Then check if that object is implementing your interface, if it is, you know it’s an interactive object and you should display a prompt to click E. (This is a simple way of doing it but, should give you some idea).
Obviously you would limit what actors implement the interface to only the specific interactive ones, so if you had more interfaces, don’t add them to ObjectInterfaces.

thank you so much!!
I’ll give this a try tonight after work :slight_smile: