The reason this is a bit harder is because im draining stamina on movement. I know there are hundreds of tutorials with sprinting but it’s not what I’m doing.
Here I am trying with the functions for draining and regening stamina
Ah you make a good point. Basically it’s going to be an rpg where travelling can’t be done all the time or if you do then it would have to be some walking as well. The character could jog from place to place but just like in real life they are going to get tired. Moving fast is done by a slider I made that controls the movement speed so I want to first get it to the point where the stamina bar drains on movement before I move to draining in proportion with velocity of the player character. The thing that doesn’t work is the stamina bar not draining and I assume the regen doesn’t work either.
• what blueprint are we looking at?
• do those Prints manifest, if so, does it make sense what they print?
• what calls those event?
• do the stamina variables have default values that make sense here?
-We are looking at BP_PlayerController right now, since all functionality to do with the pawn is in here.
-I don’t know what you by “prints”. I can make sense from a lot of it but I’m just having trouble getting it to work fully.
-At the moment it is nothing since calling it with Beginplay and Event Tick causes them to run at the same time and ignore the conditions I have set up.
-Stamina Variables should make sense, There is a max stamina which is 100% and then stamina which is initial stamina which is the value that should change and is also at 100% on the progress bar.
You placed Print String nodes there - do they print? If no, see below.
-At the moment it is nothing since calling it with Beginplay and Event Tick causes them to run at the same time and ignore the conditions I have set up.
If you do not call those events, they will do nothing. You have logic that is yet to be utilised.
That’s the problem for me I think, I don’t know how to call the events since when I tried calling the events they trigger at the same time and ignoring the conditions.
In event tick, read commanded movement input from the character. Multiply by delta time, and remove from stamina. If commanded input is nothing, then instead recover stamina (again, multiplied by deltatime)
You could also detect whether the character is actually moving, and how fast, by reading actor velocity.
It’s similar but not quite the same, all the youtube tutorials are used with a sprint system where I will be doing it with just movement and then eventually scale it with an adjustable movement slider.
I think the main issue at the moment is to try to get the function working since I’m not getting the stamina bar to drain at the moment. I tried calling them through event tick and begin play but it’s not working at the moment
Put this in your Character; the stamina will drain.
If your problem is “how do I display the stamina from the Character,” then that’s a UI Widget update problem, not a movement stamina drain problem.
Do you know how to update the value of a Slider widget from the Character?
Typically, make the Player Controller add the Widget to the player’s screen and store in a variable; make the Character get the Player Controller and cast to the appropriate class, then call into the Widget to update the value.
Separately, you need to also update your movement code to not issue any movement if the stamina is at zero.