Casting To Actor In World

hi i am making a blueprint game. i have a ui widget blueprint that needs to get a variable from a actor placed in the world. i am using casting but i cant find something to properly go in the object node. how can i get this variable? please help. thanks.

You can get it a few different ways, the easiest being “Get All Actors Of Class” Get 0, if there is only one of that class in the level.

A few other ways to do it, since it’s already placed in the level, you can get the reference in the Level BP, and send it up somewhere that is easily castable (such as GameMode, GameInstance). Or via some BPI logic.

There are a lot of different ways, just depends on your logic to be honest. I don’t know if the widget is created by that actor or not, or if it’s the player. Etc.

Here is an awesome video that can help you out, I HIGHLY RECOMMEND you watch it, even if it’s a bit lengthy, the wealth of information in this video will make you a better developer overall. I promise.

Thanks for the video Newest, I learned a lot but it didn’t help me find the answer. I ended up just sending the variable from the placed actor, to the player pawn then to the UI because the player pawn is easy to reference.

Sounds like what I wrote (easily castable) :wink: