How can I display a variable from an instance of a class blueprint using a UMG widget?

I’m trying to do something similar to this tutorial: https://docs.unrealengine.com/latest/INT/Engine/UMG/QuickStart/4/index.html

However, instead of displaying variables stored on my character, I’m trying to use a variable from a different object. I’ve created a class blueprint called TimePylonBP and placed it in my level. TimePylonBP basically speeds up and slows down global time based on the player’s distance from it. It stores this info in a float called CurrentTimeScale.

I want to display CurrentTimeScale as a percentage or progress bar or something, so that you can easily see how fast time is going. I’ve followed the tutorial I linked above, creating a widget, and binding a progress bar to the function GetTimePercent:


But CurrentTimeScale doesn’t seem to be updating at all. It should be non-zero, because I use it to calculate the time dilation which works in gameplay, and yet:


The grey bar at the top is my progress bar, so the actual widget is displaying properly. And GetTimePercent is getting called (that’s where the debug 0s are coming from every other line).

My current guess is that the variable PylonRef refers to the generic (???) class blueprint TimePylonBP and not the specific instance that I have actually placed in my level. So how do I go about getting a reference to that specific actor?

In another blueprint tutorial, I remember having to physically pick the instance from a dropdown (click on the object in the viewport > details panel > select instance), but this was for communication between two object blueprints or class blueprints or whatever. My widget blueprint doesn’t exist in the world, so I don’t think I can do the same thing.

What am I missing here?

Your assumption seems correct. Wherever you add your NewWidget to the viewport you may want to set it’s PylonRef immediately after that.

Okay I understand what you’re talking about… but I still don’t exactly know how to set PylonRef to a SPECIFIC actor. I set up the HUD in the Character blueprint:

There are a few options here. You can assign a tag to the pylon in the level then get all actors of class and check against the pylon tag to see if it’s the correct one.

You could also assign it to an event in the level blueprint. then reference the pylon that way. Then all you need to do is get the player and assign it a reference of the object. This option has minutely more memory usage because you need a reference in the player character as well as the widget.

Okay, so I found this tutorial that I think describes the technique you’re talking about: https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/FindingActors/Blueprints/index.html

Problem is, I can’t seem to implement the Cast To node (which in my case I think should be “Cast to TimePylonBP”):

Any thoughts?

If you are not able to see the cast in your script, make sure the pylon is fully compiled and saved. It should let you cast an actor to anything. that is based on an actor. If you managed to place a non actor in your scene somehow I wish to know this witchcraft.

Also, it should be the same as in the get all actors of class node. It will be written in blue text. I generally just type the whole thing out until it figures out what I need.

Anyway. This is a quick example I put together that finds an actor of class Test in the scene and checks if it has the appropriate tag labeled “correctActor”. If it does it outputs it’s name to the screen. then says done at the end of the loop. I made a point to put this in a player controller so it fits best to your needs.

Thanks so much with your persistence with this.

I had a bunch of stuff written about how I was pretty sure TimePylonBP was an actor, and asking specifically how you spawned the Cast To Node, and while I was writing, I was mucking around with settings…

I know there are some issues with Casts showing up in the context menu in 4.5.1… there’s this little checkbox called “Use New Blueprint Menu” or something like that under experimental options that’s supposed to fix it.

ANYWAY… with that checkbox ENABLED, you can see all the… I dunno… default (??) Cast To nodes… but it looks like you can’t create casts to any of your custom actors (if that makes sense)

Bottom line, I think there is only one permutation of Use New Blueprint Menu and the Context Sensitive checkbox in the blueprint editor that would actually let me create the correct Cast To node:

So… yay! I think that’s fixed it. I will try and implement the rest of the check later today. Frustrating that I was getting hung up on what basically amounted to a UI issue… I spent about half a day yesterday trying to get this to work :S

Well, the important part is that you got it to work. Hopefully the rest of the example I posted will help as well. :slight_smile:

Yup. The rest was a cake walk once I got the cast node working.

Thanks again!