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"

HELP! Communication between Widget and BP?

Hey there! I'm having some trouble trying to get something in movement.

I have a widget that i'm using as screen for a phone I have on the scene. The widget and the phone are different objects. I want to bind some text and a progress bar to some variables on the phone. In a similar scenario I used the Cast to but it doesn't work (Accesed none trying to read property K2Node_DynamicCast_AsSmartphone_BP from function: 'Get_FirstHour_Text_0' from node: Return Node in graph: Get_FirstHour_Text_0 in object: ScreenWidget with description: Accessed None trying to read property K2Node_DynamicCast_AsSmartphone_BP)

Any ideas?

This are the variables: alt text

Product Version: UE 4.12
Tags:
variables.png (7.4 kB)
more ▼

asked Sep 25 '16 at 08:07 PM in Blueprint Scripting

avatar image

RainbowCookie32
29 7 12 15

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

1 answer: sort voted first

First I would create a Blueprint that contains both your phone and your widget. Then you can create a variable that let you access your widget:

alt text

While you can bind your widget variables to your BP, this is not the most efficient method to do so. I would recommend that you create a macro that is Names SetHealthBarValue, and what it does is set your HealthBar variable value, then it will access the widget and change the health bar, that way you only update your widget when the value changes, instead of every frame.

If you have a text variable in your widget but it doesn't seam to show up, make sure your text has this checkbox checked:

alt text

capture.png (59.6 kB)
capture.png (7.2 kB)
more ▼

answered Sep 25 '16 at 08:45 PM

avatar image

Night Watcher
1.7k 44 12 71

avatar image RainbowCookie32 Sep 25 '16 at 09:19 PM

I didn't get this part: First I would create a Blueprint that contains both your phone and your widget

avatar image Night Watcher Sep 25 '16 at 09:23 PM

Create a Blueprint that has your phone Mesh, your phone variables, and your phone widget (Screen). Set the widget component class to the widget you created alt text

capture.png (14.5 kB)
avatar image RainbowCookie32 Sep 25 '16 at 09:28 PM

Done. But where should i cast it?Don't have any playerhud

avatar image Night Watcher Sep 25 '16 at 09:29 PM

PlayerHUD is the name of my widget, you should cast it to the name of your widget

avatar image RainbowCookie32 Sep 25 '16 at 09:31 PM

My widget doesn't appear

avatar image Night Watcher Sep 25 '16 at 09:32 PM

uncheck the context dependent checkbox in your search menu

avatar image RainbowCookie32 Sep 25 '16 at 09:34 PM

Done. What about the set Phone Screen?

avatar image Night Watcher Sep 25 '16 at 09:36 PM

You widget component that you added to your blueprint you should select it and go to it's detail pannel, and select your widget as your parent class of the widget component

avatar image RainbowCookie32 Sep 25 '16 at 10:09 PM

Where do i do that. Sorry I'm a bit noob

avatar image RainbowCookie32 Sep 25 '16 at 10:13 PM

In details i'm not seeing how to do that?

avatar image Night Watcher Sep 26 '16 at 01:44 AM

alt text

capture.png (48.9 kB)
avatar image RainbowCookie32 Sep 26 '16 at 01:54 AM

Done. Where did you get the Set Phone Screen on the bp?

avatar image RainbowCookie32 Sep 26 '16 at 01:56 AM

Also I'm getting this compile error from the Cast to ScreenWidget: Warning 'Screen Widget' does not inherit from 'Scene Component' ( Cast To ScreenWidget would always fail).

avatar image Night Watcher Sep 26 '16 at 02:00 AM

show me a screenshot of your BP that include your code, the components, and the warning

avatar image Night Watcher Sep 26 '16 at 01:59 AM

it's a variable that I created so I don't have to do a cast each time I want to acess the screen, I just do that once. Just right click the outpust pin of your cast node (ex. "As Player HUD") and select promote to variable, then name the new variable Phone Screen

avatar image RainbowCookie32 Sep 26 '16 at 02:03 AM

alt text This is what I'm trying to copy from your example, just added the set

bp1.png (256.8 kB)
avatar image RainbowCookie32 Sep 26 '16 at 02:03 AM

I'm getting a bit confused

avatar image RainbowCookie32 Sep 26 '16 at 02:07 AM

I can't put all the bp in one screenshot

avatar image RainbowCookie32 Sep 26 '16 at 02:10 AM

I just want to get a value from the bp to my widget, it can't be that hard

avatar image Night Watcher Sep 26 '16 at 02:11 AM

it's not that hard, you are only using 3 BP functions

avatar image Night Watcher Sep 26 '16 at 02:10 AM

it's ok, I saw what I needed to see. You should use this instead of the get child component. alt text

capture.png (37.2 kB)
avatar image RainbowCookie32 Sep 26 '16 at 02:12 AM

Done. No warnings. What's next?

avatar image Night Watcher Sep 26 '16 at 02:15 AM

Make this code execute on event begine play. All the variables of your widget can be accessed from your PhoneScreen variable

avatar image RainbowCookie32 Sep 26 '16 at 02:17 AM

Ok, now on the widget I can get (disabling context sensitive) for example the battery level, what should i use as target?

avatar image RainbowCookie32 Sep 26 '16 at 02:19 AM

alt text

widget.png (232.0 kB)
avatar image Night Watcher Sep 26 '16 at 02:20 AM

You don't need to disable the context sensitive. This is how you set the health bar value, also you remember it's in percent, therefor you value should be between 0 and 1 alt text

capture.png (41.0 kB)
avatar image RainbowCookie32 Sep 26 '16 at 02:22 AM

If i don't disable context sensitive, the variables doesn't appear

avatar image Night Watcher Sep 26 '16 at 02:23 AM

As for the screenshot you showed me, don't use bind, it's not efficient, just change the variable directly in the blueprint we just created like I showed you each time you change the value, it's more efficient.

avatar image RainbowCookie32 Sep 26 '16 at 02:29 AM

I love you Night Watcher! It's working! Thanks. I was stuck with this since yesterday. I was about to break my screen with my head

avatar image Night Watcher Sep 26 '16 at 02:31 AM

glad I can help :)

(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