First of all, you are still using the input IA_Interaction inside your generator and not in your character! That’s not good! I highly recomend you to watch this tutorial about how to create interactable objects before going any further!
Regarding your current issue, the problem is you are updating the worng widget! You are spawning a widget on the player’s viewport and updating that one with the following code:
Instead of updating the one you are turning on in your BP_ControlDesk.
I’d like to see where are you turning on and off your widget, because you need to reference in your generator exactly that already created widget instead of adding a new one to the viewport.
In addition, once you get the reference to the correct widget in your Generator, you can update the widget using its “Update Generator Timer” immediately after you “Set Current Time” in your Set Timer By Event.
So I tried finding a way to reference the correct widget in Generator, but couldn’t find a way. Also in this video you can see I’m using the “Interaction” system, it’s only temporary for testing purposes and will be optimized later.
For the correct reference I tried a lot of stuff, like making the widget into a variable and placing that in the generator. But couldn’t find a way to do that.
Everything you see in “BP_Generator” is messy and ofcourse not gonna stay like that.
Ok, exactly as I thought! You are not assigning an owning player nor a reference to your generator!
If I understood, you want to show the progress bar when you are watching the cameras, right? And you are turning them on and off properly as I can see in the video.
To make it work that way, you will need to change a few things in your three BPs.
A) First of all, you will need to rework your Widget:
Add a variable to use as Generator Reference, make it Instance Editable and Exposed On Spawn:
Create an Update function and connect it to the Event Tick (as you did before, but this time will be so much easier as you have a reference of your Generator):
B) After this, you will need to remove everything related to the UI from your BP_Generator, as it is not its responsibility to manage the UI! We will manage all that part from the BP_ControlDesk.
In addition, I need to clarify you will trigger the event to start the generator from your Control Desk!
C) Now you will need to create a variable in your BP_ControlDesk called “Generator Ref” of type “BP_Generator” and make it Public (the eye icon at the right of the variable). That way, you will be able to pick the generator as reference from the Details panel in your editor.
In the next few images you will see how it should look! The white cylinder is the generator, sorry for the art haha:
Now you will start the Generator timer and create the widget when the player interacts with the Control Desk, but you will need to check if it is already active before, so you dont activate it more than once:
As you can see, I’m using a flip/flop to turn the Widget on and off. This saves you a lot of space and logic. This node triggers A first, then B, then A again, then B again, and so on.
The rest of your logic should work without any more changes!
Thank you so much! I got the progress bar working, but there’s just this one bug where if I leave the cameras and go back, it doesn’t work then.
Also I get the following error message the second I open cameras (Even the first time)
Blueprint Runtime Error: “Accessed None trying to read (real) property Generator in WBP_CamerasProgressBar_C”. Node: Set Percent Graph: Update Bar Function: Update Bar Blueprint: WBP_CamerasProgressBar
I will try to fix this aswell, but knowing my skills I might not be able to. If you’d happen to know what’s up, I’d appreciate it a lot!
That said, I do greatly appreciate the effort you put in helping me out here!
(These pictures might or might not help, but might aswell post them :D)
That message indicates you are missing the Generator reference.
As you can see in the following image, you have two differente variables of type “BP_Generator” (“Generator” and “GeneratorRef”). You should keep only “Generator” as it is the one you are using in the function.
Check all the possible references in the rest of the Widget’s graph, so all of them uses the same variable!
After fixing that, you need to right click on the node where you are creating th ewidget, and click on “Refresh Node”, so the incorrect ping dissapears. Then, connect the Generator referente to the correct pin. You can see in the next image where to change that: