The easiest way to do this is to store a reference to your widget on the blueprint that created them, your playerController for instance… then on your widget, cast to the playerController and send it the data into a function or a custom event, and have that custom event or function send the info to the other widget.
Hi, I was wondering if someone could help. What I’m trying to do seems like it should be easy, but I’m new to UE4 and none of the tutorial videos have the same type of game I’m trying to make.
Rather than have a 3D or 2D character, I’m trying to make a sim/management game, like a Football Manager kind of thing, where the game is database and UI driven; I’ve attached a couple of images of what I have so far.
The first is a screen where the user uses left and right arrows to select the fighters they want to use for the fight. All the variables are driven from an imported CSV file, and they are changed by two variables, A_FIGHTERNUM and B_FIGHTERNUM, which are driven by the left and right arrows.
After hitting continue, the user goes to a press conference mini game in a new widget, then will go on to the fight. In the mini game, I want the user to be able to select a “strategy”, and the variables from the first screen will be loaded in the "99"s shown to help the user decide. Names will also be shown.
All I need to do is get the fighter numbers from the first widget (Fighter Select Screen) into the second (Strategy Select Screen) and then I can return rows from my database again and set up bindings…
Unfortunately, I’m not sure whether I’m supposed to be casting, referencing, involving some sort of parent child relationship, etc, and it’s a problem that’s limiting me to just building a UI, rather than a “game”. As you can probably tell, I’m working in Blueprint, rather than code.
Thanks in advance.
Thanks for replying, I’m still pretty new to everything and I still don’t particularly understand BP comms and casting!
I began by making a widget called UI_FIGHTER_SELECT_SCREEN and in that there are integer variables called FIGHTER_NUMBER_A and FIGHTER_NUMBER_B (these can be altered via the UI).
In my player controller, I have the same two variables, as integers. Am I right in thinking that when I click proceed, I want to cast to the player controller variables and set these to the numbers selected in the UI? Then, upon loading the next widget, get those variables via casting again and set new variables in the second UI?
No worries,
First thing I would do would be to create two WIDGET variables in your playercontroller and set them when you create your widget ui, so that you have a widget to reference in blueprints
Second, I would create a function on each of your widgets that are capable of altering the values of your ui variables with an INT input
Third create two functions on your playercontroller with an INT input, one that addresses the first ui, and one that addresses the second ui. Use the widget variables to address them, and call the function that you created in step two and pass through the INT input from the function
Fourth, use whatever changes the variable to call the function on the playercontroller and pass the value from the UI to it…
To call the playercontroller simply use “get player controller” ID 0 should be fine, drag off of it and choose cast to, and whatever you named your custom player controller to. This will give you access to the functions that live on the player controller, drag off of the player controller output and type your playercontroller function, and you have a decent forward push
Button pressed in UI A → Value passed to player controller → player controller passes it to UI B → value changed in UI B
use visibility to control the UI so the values are always present, don’t destroy the ui, otherwise you’ll have to store the variable on the playercontroller and pass it in every time you create it
Hey, many thanks for this. I’ve got my head around how the variables and casting work now. I was essentially trying to cast the wrong way before. The references are all working now, Onwards and upwards to actual game making now, thank you!