Hello! So I’m making a progress bar for my generator, but I don’t know how widgets work and AI was not useful, if anyone knows how to fix the problem, I’d appreciate it!
[TimeLimit] And [CurrentTime] Both use the same idea/logic in BP_Generator
Looking at your code (second image) I can see you are missing the part where you set the Current Time and Time Limit variables.
You are getting the variables from Generator Ref but you are not assigning those values to your widget’s variables. So your widget’s “Current Time” and “Time Limit” variables are empty when you try to use them.
Immediately after “Get Current Time” from your Generator Ref you should drag your “Current Time” variable, choose “Set” and assign the pin “New Param” to it. Then, you need to do the same with “Get Time Limit” and your “Time Limit” variable.
The rest of the code seems to be alright and should work perfectly with those changes!
Where are you spawning the Widget? Are you adding it to the viewport anywhere? Are you setting the Generator as reference for that variable when you create/add the widget to the viewport?
You should have something like the code abouve in some place to make it work. I would put it in your Generator Activation, so it spawns when the generator starts working.
As you can see, if you have your variable properly setup in your Widget, you need to feed it with a “Self” reference (which in this case is your Generator, as you are adding the widget from there), and the player controller as its owner (so it spawns on the player’s screen). You should also store the widget as a variable (I called it GeneratorUI in the example), so you can remove it from viewport when needed.
If you don’t have this code anywhere, your widget doesn’t know when/where to spawn, nor who is it’s owner, nor what generator it should use as reference!
With that, you should be able to use your widget properly! But there is another issue which could lead you to many problems in the future, and it’s not related with the widget part.
You should NEVER use inputs out of your character blueprint or your character controller blueprint! You are using IA_Interaction inside the Generator and that is a really bad practice! That inputo should be in the character or controller BP, and check if it can interact with the generator! Be carefull with that!
Let me know if this worked for you or if you need more help on this
Thank you for the support! I did the code you suggested and it worked!
Though that made me wonder if I can make it only show up in my “BP_ControlDesk” AKA CCTV, so when the player clicks on the CCTV mesh, the timer begins and the progress bar only shows up in the said CCTV (WBP_Cameras, this includes the “Exit Cameras: RMB” and such)
I made a duplicate of the WBP_Cameras widget, which is the progress bar seen working in this video.
(In the video I’m using “Event beginplay” as an example so it starts instantly, I’d like for it to start only after Interacting with the laptop (BP_Controldesk)
Sorry if this is a bit confusing, but nonetheless thank you so much for the support!
Regarding your new question, if I understand it, you want to show the progress bar in your “in-game” laptop, right?
Now that you know how to add and update a widget, I recomend you to watch this video , which explains how to create that king of widget!
Watch it and let me know if it worked! If it doesn’t work, I suggest you to create a new post about it (you can tag me there if you want) and mark my previous answer as “solution” for this post’s original question! We can keep working in the new post if needed