No worries my pleasure, community / forum is what it is for.
So you don’t need this anymore actually if you try to replicate what I demonstrated.
Cause we check stamina->cost on tick. Meaning if on tick something matches will already cost stamina.
Let me walk you through a better version step by step. A working example design of what you want. Both examples should work its just reordering cause of design aspects.
1- Can I sprint? if conditions pass we mark as wants to sprint
You can do whatever condition you have. Like crouch, aim, ads ..
2-Handle Sprint
At that moment what can we do? Output integer of movement mode.
3- Execute
on 0, 1, 3, I decrease stamina . on 2 we give stamina
However additional design aspect if player goes low stamina and still tries sprint we even cost more, if stops sprint at that moment (low stamina) → we regen but less (0.25) till its normal stamina then goes movement mode 2 after a while and regenerates stamina regularly.
Here is full snippets
Can be many things however I felt like if player is low stamina, they have to decide wheter they should keep pushing or not to sprint. Since now we have outcomes if we push sprint.. it costs more however we still move.. You can even give that a movement mode like 4 and have a different speed.
Imagine this is a horse racing or player is riding horse escaping from enemy. It’s on players hands strategically when to sprint when to rest horse.
try to replicate these and if you want to push further aspects, we can push together.
- Cost more stamina on climbing less on flat surfaces
- Time passed with sprint. Curves over time costs etc.







