Download

calling widget BP function from PlayerController BP

Hi all,

As a test i’m trying to change my widget BP (Game_UI_BP) score from a key event in TetrisPlayerController_BP, but it doesn’t work.

In my widget blueprint i created this function which updates score (Level variable is the text variable to update) :

http://img11.hostingpics.net/pics/2227916119.jpg

I created an actor which contains this widget as a component :

http://img11.hostingpics.net/pics/2089705320.jpg

TetrisPlpayerController_BP :

http://img11.hostingpics.net/pics/6856567421.jpg

I think it should work. Is this a bug ? If not any help would be much appreciated

Help please

Are you sure you are using this controller? Put a print node after the space to quickly test it.

Hi, yes i am

Hi all,

As a debug prupose i have tried many print strings and in Game_UI_BP not only the function Update Score Display is called but also the argument Score is correct.
As i just read in another topic, it is a well known bug : we cant edit dymamically 3D widget text. I’m gonna try to upgrade UE4 to its latest version to check if this bug is solved. And if it’s not the case i’ll use regular viewport widget (not Actor one)

I use the Widget Component in my VR Game and that updates fine. So you should just swap to that if the other one doesn’t work in newer versions (:

Hi eXi,

The latest version upgrade didn’t fix the bug. So i used regular widget (added to viewport). And it works like a charm.
Next time i try a 3D widget in another project, i’ll try your widget component instead of widget text component. Thanks

For all UMG stuff i always make either Dispatchers in Player controller or add blueprint interface there.

For dispatchers:

  • make dispatcher event that sends out all variables needed for UMG widgets. For eg health, ammo left, name of gun etc. All that stuff in single event dispatcher, making struct helps here.
  • all widgets that need such info just assign to that dispatcher, then in player controller every tick or when you need update it, you just trigger that dispatcher function

For blueprint interfaces version:

  • make blueprint interface, add it to player controller.
  • create blueprint interface functions for all variables you need read.
  • I then in widget find player controller (in singleplayer it would be GetPlayerController node). Since player controller has added blueprint interface you can just use those implemented functions to read variables.
  • also do not forget to actually implement code inside blueprint interfac efunctions in player controller

Hi and thanks,

IS there a good tutorial about blueprint interfaces version ?

this can help:

Blueprint interfaces is just improved version of normal “get actor reference” then cast to then do whatever way of communicating. It makes all easier because you do not need to make multiple versions of code for each widget (class of umg).