x

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"

Casting from widget to widget fails

I am trying to get a variable from a UMG widget to another using the node "Cast to", however for some reason it always fails. Here is how the blueprint looks like:

alt text

Begin Game HUD is a reference to the other widget created manually in this blueprint, so i don't really know why it is not being successful.

Product Version: UE 4.7
Tags:
more ▼

asked Jul 25 '15 at 06:10 PM in Blueprint Scripting

avatar image

Nargarcyz
34 4 6 8

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

1 answer: sort voted first

Where have you set the var "Begin Game HUD" with a value? Because if you just said to the Engine that is the same type as BeginGameHUD then the value inside of the var is null.

more ▼

answered Jul 26 '15 at 11:38 AM

avatar image

Fanto88
318 23 15 28

avatar image Nargarcyz Jul 26 '15 at 03:46 PM

As you guessed, i set the variable to BeginGameHUD. So what should i put instead? I have been trying but didn't solve this.

avatar image Fanto88 Jul 26 '15 at 03:53 PM

When you create your "BeginGameHud" with the node called "Create widget" you should save the out pin into a var, then pass that var to the widget. This is TODO list:

1) Create the widget Begin Game HUD through the "Create widget" node. 2) Save the result of that node into a var 3) Create your second widget(the blueprint) where you need to get access to the info of the first widget 4) Create a var into the second widget with type "Begin Game HUD" 5) Click on that var and check "Editable" and "Expose on spawn" 6) Create the widget with "Create widget" node then insert the outpin of the "Create widget" of the point 1) into the new var

I can create the script if you didn't undestand something

explainmore.png (224.4 kB)
explain.png (223.3 kB)
avatar image Nargarcyz Jul 26 '15 at 04:00 PM

Understood all but point 6. Why do i need to create the widget again if i only need to access it. However, even when i tried doing 6), i didn't get any node asking for a "BeginGameHUD widget" input. Could you please shine some more light on this?

avatar image Fanto88 Jul 26 '15 at 04:13 PM

Sorry about the 6), you don't have to recreate the widget, i just said it twice, my fault.

I created a simple example.

alt text alt text

In the explainmore.png i show you how the var should be (It's the second widget, the one where you need to use the cast). Explain is where i create the 2 widgets.

PS: If you still have problems with that you can send me the project and i will take a look for you

explainmore.png (224.4 kB)
explain.png (223.3 kB)
avatar image Nargarcyz Jul 26 '15 at 06:10 PM

Oh i see. I didn't know why you were creating two widgets because i was thinking that the widgets would show up on EventBeginPlay, but i forgot you need to add them to the viewport. Now if i understood everything correct is that doing that the variable created can now be used to cast. I'll try to implement this.

avatar image Fanto88 Jul 26 '15 at 06:14 PM

Yes, if you do like this you should be able to use the cast node without problems. If you have more question just ask and i will try to help you.

Davide.

avatar image Nargarcyz Jul 26 '15 at 06:31 PM

Allright, it is working as intended. Knowing how to cast from widget to widget will make my project a lot easier. Many thanks for spending your time to help me and for such a useful tip Davide!

Oscar.

avatar image Fanto88 Jul 26 '15 at 06:32 PM

No problem, glad to help. Please, accept the answer for tracking purpose. And, optionally, click like on comments.

avatar image Nargarcyz Jul 26 '15 at 06:36 PM

Totally forgot about that, i'm pretty much a noob in terms of this website. Anyway already accepted the answer and thanks again!

avatar image Fanto88 Jul 26 '15 at 06:38 PM

No problem . Check only one that is labeled as " solved " , because I see it as yet unresolved .

(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