Hello,
I’ve built a basic stamina system for my survival project, but have encountered a small yet significant issue. I have my sprint function bound to a L Shift action binding and when I press it, my speed increases and my stamina decreases. I also have a check for velocity to make sure that the player is moving before the stamina is drained. This also works.
The problem arises when I start the game, press shift, but don’t immediately start moving forward. No stamina is drained, which is correct, but if I continue to hold it down and then press W to move forward, it doesn’t drain stamina. I have my ReduceStamina function called in the velocity check. I believe the problem has something to do with the fact that the if statement is only being called once, then the velocity is read as zero and it doesn’t recheck it. I tried a while loop and a for loop and my computer crashed.
The forum won’t let me share images of my code because “I’m a new member,” so hopefully you guys can understand what I’m describing. Any advice is welcome.