So I have a custom status value bar with negative changes set up with a delay in the status value itself and everything is working as intended except for the very first instance of the status value changing. When I change values for the first time the negative change does not seem to be registered resulting in the following value bar with no negative changes:
When the value is reset and I change it again it works as intended showing the following changes:
The only custom code I wrote that changed value bars was that I made the countDelay variable of a status value public so that I can change it during run time. Basically I have a queue action system where the player can queue up actions and the amount of stamina being used is represented by the negative change value bar. If the player moves or cancels their action they get refunded the stamina. The status value UI setup is as follows:
Effectively the stamina bar should show a negative change for 50000 seconds before finally decreasing (an arbitrarily high number so that it effectively shows the stamina being used for as long as the player has an attack queued and unless they wait 50000 seconds to input their command it wont decrease). Upon inputing their command I update the count delay to 0 and then the status bar decreases.
My game is a state machine so only one active state can be happening at a time. The player can queue up a list of attacks and they wont be executed until the player hits the input (space) key.
There are only two instances of code that I change count delay to 0. The first one is in my Refund Stamina method which is only called when the player queues up attacks and then makes a movement, cancelling the attacks. When I refund my stamina after the first queued attack, IT DOES refund the missing stamina despite no negative change, and if count delay were being changed by this method then the stamina shouldn't have decreased at all. So I can rule out this being the source of the issue. The method looks as such:
The only other method changing count delay to 0 is the following:
This is the method that takes all the queued commands from the player and runs them out to completion. The logic is as follows. There is a counter being kept track of for the amount of attacks the player is making. The player attack method simply executes the queued ability which on execution end changes the "attackComplete" variable to true, continuing the cycle for each attack that is queued. After if the counter has increased (1 per attack), I reset the count delay and the stamina is spent for good.
This function can only be called when the player presses the input key when an action is queued up. Looking at the console in game, no abilities are executing when I queue up the first attack and debugging shows that it is not being called.
So I am at a loss as to why the very first status value change does not register the negative change. Any help would be appreciated, thank you for your time!
Since this involves custom code, it's hard to say where it's coming from. Without the custom stuff, it's working normally in my tests.
Try adding some debug output whenever countDelay is changed to see where this is coming from. The initial negative change not being displayed and immediately updating the value hints at the delay being set to 0 for that one case.
Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found. If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Without the custom stuff, it's working normally in my tests.
Try adding some debug output whenever countDelay is changed to see where this is coming from. The initial negative change not being displayed and immediately updating the value hints at the delay being set to 0 for that one case.
If you're enjoying my products, updates and support, please consider supporting me on patreon.com!