Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:

alt text

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:

alt text

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?

Product Version: Not Selected
more ▼

asked Nov 16 '14 at 05:13 PM in Blueprint Scripting

avatar image

3 3 5 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

more ▼

answered Nov 16 '14 at 05:38 PM

avatar image

2.1k 104 74 163

avatar image fleamo Nov 16 '14 at 06:56 PM

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:

alt text

avatar image Justin.Dooley Nov 16 '14 at 07:14 PM

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.

avatar image fleamo Nov 16 '14 at 09:31 PM

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"):

alt text

Any thoughts?

avatar image Justin.Dooley Nov 17 '14 at 05:18 AM

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.

alt text

example.png (102.5 kB)
avatar image fleamo Nov 17 '14 at 02:09 PM

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:

alt text

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

avatar image Justin.Dooley Nov 17 '14 at 02:57 PM

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

avatar image fleamo Nov 17 '14 at 10:08 PM

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

Thanks again!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question