Got an issue where I’m trying to reduce the stamina bar width but doesn’t seem to work, In the video you can see the stamina value does a jump but doesnt have the bar itself move. The issue might be because I am using another blueprint to host all of my widgets so the width overide might not be following through but the stamina bar value is. Not sure what the issue is at the moment either way.
Do you think you could be a little more in-depth with your intent here? Are you wanting the bar itself to shorten overall? Are you trying to lower the maximum value? What’s happening here in the context of your game, is what I’m trying to figure out.
If you believe there are other parts of the code that may be overriding this, please post code snippets of anything that may be related (going back to the start of the events) so we may be able to see the bigger picture and figure this out!
Ah my mistake, The mechanic is after a certain amount of stamina consumed then the sizebox which is part of the widget would increase by 15 which would push the green bar to the left which would give the illusion that there is a type of grey stamina that can’t be regenerated until conditions are triggered (not done yet)
This function is done in my TopDownCharacter blueprint. The actual stamina bar is called in another blueprint that hosts my other widgets.
Have you tried reducing the width of the stamina bar alongside increasing the size of the stamina bar reducer? (Also make sure the bar is linked to a value, otherwise it’s 0/0 and therefore not going to have a size.)
It seems I have a cast that is failing, the Stamina Bar reducer Reference is not an actual object so I’m not sure what to do from here. It’s not referencing right!
Ahhh ok. So it’s a matter of casting. So to explain casting:
GENERALLY casting will only work if the object you’re casting from is higher in the hierarchy of parentage. So like, casting a third person character into a specific third person character to access specific variables unique to that more specific version of TPC.
So the question here I have is: What is BP_StaminaAndFatigue? Is it a character component? A widgetBP? Because whatever it is, it can’t be converted from your stamina bar ref to whatever it is and back.
BP_StaminaAndFatigue is a user widget. So my thought was to create a variable that is a user widget object reference within my character blueprint. This causes the cast to fail unfortunately. I think my widget creation is not made individually, I use another blueprint to be a host/template other GUI’s. This is then created for the game in player controller so there is no individual reference to the StamAndFatigue blueprint which is what is hurting me a bit.
Where are you assigning the “Stamina Bar Reducer Reference” variable that you are using as your input object for the cast?
Is this picture your BP Main Hud Widget?
After the widget has been assigned in BP Main Hud Widget you need to promote that specific piece to variable within your player BP and assign it as part of your HUD setup code.
For it to be findable, go to your event graph on BP Main Hud Widget and find the “Stamina Bar Reducer” in the variables to the left, and open the eyeball to make it public. That should make it findable if you “Get MainHUDref” after you “SET MainHUDref”, or just drag off the blue outgoing pin on the “Create BP_MainHUDWidget” and do a cast, then use a “GET” command to get your reducer. I hope literally any of this makes sense, UI can get really loopy.