Simply put, I’m trying to make it so the player can look at an object and the object’s name (a chair for example) will show up on-screen via a UI widget.
I have got something close by using collision boxes, but that just won’t do for smaller objects.
The chair is an actor BP and this is where I figured I’d change the text variable in my UI widget (see screenshots)
How can I make it so the text change is triggered by the player looking at the chair rather than colliding with its collision box?
The way I do it in my project is by using a line trace instead of collisions/overlap. All my actors I want to be interactable, come from a Master Actor and implement a particular interface. So when the line trace hits something that implements that interface, I cast to the master actor (which contains a Struct that has all the details about the actor which i modify for each child), and then show a widget i’ve already created and referenced at begin play and then display it on screen and modify the text (such as name) with details from the Struct of the actor.
Only thing this way is you need to run it off tick, but I have nothing else on tick (apart from day/night cycle) and this makes no difference whatsoever as far as performance for me whether I have this enabled or not since it’s just a simple line trace and I don’t run it every frame. The tick interval is set to 0.1 in my case.