I need help with my Stamina meter

0 favourites
  • 9 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • So, I'm trying to make a stamina system in my game, where you press shift and you begin to run. It works when I press shift, however, it won't return to normal when I release it and I'm not even sure the stamina variable works either. I seem to return to my normal speed for a brief moment when I release the key, only to be sent back to the running speed continuously.

    I'm also trying to figure out how to make a HUD Stamina Bar, but I'm not sure how to do it.

    Tagged:

  • You can check all this in debug view to make sure the car speed and variables are what you expect. I don't see any logic for setting stamina back to its original value. Also is it's starting value greater than 0?

  • here's how I would do it.

    Let's say you use stamina for sprinting. I would Add to a stamina value.. meaning when its full you've taken all the power you can manage, so you need to rest. So maybe "exhaustion" would be a better variable name now that I think of it!

    So this gives you 4 seconds of sprint, if you release before you go over the 4, the stamina cools down as fast as it went on. But if you go over 4 seconds, you overheat and can't use sprint for a the whole 4 seconds and the stamina comes off in 4 seconds.

    you can play with the numbers and make it more punishing to overheat or make the dissipation faster than it goes on. In that case just do Subtract dt*2 or something, so you would keep the 4 seconds of sprint (adding 1 stamina per sec), but if you let go early, the dissipation is only 2 per second.

  • I looked at the example you made for a while and I tried it, but it still doesn't work for me. I'm sure it works, I'm probably just doing something wrong. When I press L-Shift (and I even tried L-Alt) it just makes me walk forward at the normal speed instead of the run speed. I don't know why it does this. Do you need me to send the project file?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Alright, looking at the debug layout, the variable system works fine. I just need to figure out how to make the cooldown boolean affect player speed.

    Also, do you have an idea of how to make an HUD stamina bar?

  • Alright, looking at the debug layout, the variable system works fine. I just need to figure out how to make the cooldown boolean affect player speed.

    Also, do you have an idea of how to make an HUD stamina bar?

    yes include a c3p file if you can... not the whole thing, just a small test of it.

    for a stamina bar I use a couple different objects.

    1. the bar 'holder' Sprite, that still shows when the 'fill' is empty

    2. a bar fill Tiled Background, I use TB so it doesn;'t distort when changing the width - I figure out what the full width of the fill and store that in a variable called fullbarwidth

    Then I set the width Every tick to: stamina * (tb_fill.fullbarwidth / staminaMax)

  • Sorry for not following up, but I figured everything out!

    I used a simple sprite for the bar, and each animation makes it go down one segment. I also got down the stamina mechanic, thanks for the help!

  • glad to hear!

  • I have some inquiries if it’s not too much trouble😥😥, guide me about this. These inquiries are displayed underneath here☹️☹️:

    https://www.construct.net/en/forum/construct-3/how-do-i-8/c2-mod-support-171302

    Sitting tight for most appropriate response straightaway. I’m excessively confounded here😱😱

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)