# How to get static mesh name and input it into widget

**URL:** <https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [November 29, 2023, 3:54am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568 "2023-11-29T03:54:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dxggerboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dxggerboy](https://forums.unrealengine.com/u/dxggerboy)\
**Post date:** [November 29, 2023, 3:54am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/1 "2023-11-29T03:54:48Z")

</div>

Hello,

I currently have a line trace system where if it intersects a BP actor it displays a widget saying “[F] to interact”. I was wondering how I would call the static mesh of the BP actor and display it in the widget per object rather than just the pre written “[F] to interact”.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 29, 2023, 6:46am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/2 "2023-11-29T06:46:27Z")

</div>

> [@dxggerboy](#):
>
> call the static mesh of the BP actor and display it

Have an interface return a text variable from the hit actor / component and feed it to the F widget, set the text field to that value.

Or do you mean the mesh itself rather than plain text?

---

<div class="post-metadata">

**Author:** ![dxggerboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dxggerboy](https://forums.unrealengine.com/u/dxggerboy)\
**Post date:** [November 29, 2023, 8:07am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/3 "2023-11-29T08:07:07Z")

</div>

Plain text works too, just with my line trace I want the widget to be updated with the name of the object itself. Could I do this by somehow calling a bind variable from the widget BP to my line trace BP?

I’m very new to UE5 so I’m not sure how to call variables from other BP’s.

---

<div class="post-metadata">

**Author:** ![KiiroiSenko](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kiiroisenko/32/754874_2.png) [@KiiroiSenko](https://forums.unrealengine.com/u/KiiroiSenko)\
**Post date:** [November 29, 2023, 8:27am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/4 "2023-11-29T08:27:58Z")

</div>

I believe trace returns a FHitResult struct which includes a reference to the hit actor. From there you can use get component by class and find the static mesh and then you can get the name from the mesh reference. You can also as Everynone mentioned make an interface with a single function that returns the name on your actor, cast the hit actor from trace to your interface, call that function and use the value for your widget

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 29, 2023, 8:39am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/5 "2023-11-29T08:39:19Z")

</div>

Since this can be done in too many ways, we’d need to know how you’re handling things at the moment in order to suggest something that fits right into your existing system.

> calling a bind variable

- assuming this is what you mean in the widget:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/4/4/74436848eb4ed2539dd670d0c0fbc39b9e1a39fa.png)

- assuming we’re using an interface:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/3/28357c854cca1f51c9e1ce06ca3340d735389d99.png)

- assuming we’re tracing and looking at stuff:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/c/d/2cd5491d2612b4fdec9a0f3576f9fc5b8c7a8e8d.png)

- assuming actors carry names we predefine ourselves:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/c/c/0ccd3daa800952898164a1f143fae0d64909f535.jpeg)

The end result here would produce:

* * *

As you can see I had to assume a lot since we know squat about your setup. 🫠

_Disclaimer: the above can be set up much better - it all really depends on the features and behaviours you need._

* * *

Also, here’s a link to a slightly more nuanced behaviour:

> [@Third person crosshair object highlight troubles](https://forums.unrealengine.com/t/third-person-crosshair-object-highlight-troubles/252041/7):
>
> Do tell how it goes. This can be set up with very little ticking, actually. You could even line trace just a couple of times per second, and the player wouldn’t notice. But this particular ticking is something I wouldn’t worry about. @ConvenientBox How close is this to what you’re trying to accomplish?

> [@Third person crosshair object highlight troubles](https://forums.unrealengine.com/t/third-person-crosshair-object-highlight-troubles/252041/13):
>
> The communication in the example revolves around Inheritance + Interface - a potent combo, imho. the base class implements the interface (which children inherit) the widget uses the same interface - calls children receive can be propagated: Actor → Widget Component → Widget without casting or finding user widgets (this can be done in many ways, though) the player has a collision sphere and sends an interface call to overlapped actors as we approach: [image] [image] Above, handl…

Here, each interactive actor has its own widget. There is a project link in the second post - consider taking it apart to see how it works. Should work fine in UE5 once updated.

---

<div class="post-metadata">

**Author:** ![dxggerboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dxggerboy](https://forums.unrealengine.com/u/dxggerboy)\
**Post date:** [November 30, 2023, 5:58am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/6 "2023-11-30T05:58:54Z")

</div>

Thank you for the very concise and informative help, I’ll look into this and get back!

---

<div class="post-metadata">

**Author:** ![dxggerboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dxggerboy](https://forums.unrealengine.com/u/dxggerboy)\
**Post date:** [November 30, 2023, 7:19am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/7 "2023-11-30T07:19:53Z")

</div>

The way that I am doing the line trace is similar to yours in your BP\_FirstPersonCharacter, but my line trace is a function called “Trace” in an actor component called “AC\_interactionTrace” Then the “AC\_interactionTrace” is pulled in a function called “Setup Interaction Trace” in the “BP\_ThirdPersonCharachter” which checks that the trace is a locally controlled pawn.

 ![trace function](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/0/7f02d3b12f51bbf6e9049b40677415d96ac45d22.png)

I think my question is, where would I setup the area to place a widget bind variable? In my Trace function in the AC\_interactionTrace, the Setup Interaction Trace in the BP\_ThirdPersonCharachter, or another location?

I would’ve posted more screenshots but some reason i’m limited to only one media per post.

---

<div class="post-metadata">

**Author:** ![dxggerboy](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dxggerboy](https://forums.unrealengine.com/u/dxggerboy)\
**Post date:** [November 30, 2023, 7:27am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/8 "2023-11-30T07:27:22Z")

</div>

Here’s the Setup Interaction Trace function that resides in the BP\_ThirdPersonCharacter which called the AC Interaction Trace (The line trace).

 ![setupinteractiontrace](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/3/7f3411a4a937f6e67f79fbc10ced67775df8824d.png)

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [November 30, 2023, 9:02am UTC](https://forums.unrealengine.com/t/how-to-get-static-mesh-name-and-input-it-into-widget/1430568/9 "2023-11-30T09:02:39Z")

</div>

> [@dxggerboy](#):
>
> where would I setup the area to place a widget bind variable?

- variable property binding is in the widget itself, as seen is my example
- create a widget either in the component you use for tracing or the player BP, reference it - on Begin Play is fine
- when the trace connects, set the widget’s bound text variable using the widget’s reference

* * *

Ideally, you wouldn’t use property binding which executes every frame and use an event driven approach but polling a variable for this is more than OK.
