Is this not functioning correctly?

0 favourites
  • 7 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • I have my events set up drain my character stamina when I sprint, but it just keeps draining after its used up. I have it set to a variable if greater than 0 but its still draining. And whats weird is it worked earlier WITH THE SAME EVENTS. No change, no extra events.

  • You're only setting isSprinting to false when you release the shift key, so, while you have it down isSprinting will be true, no matter how much stamina you have.

    The code should be something like:

    Keyboard | Shift is down             | set isSprinting to True 
    Player   | 8Direction is moving      |
    System   | PlayerStamina > SprintVal |
    
    System   | Else                      | set isSprinting to False
    
    Player   | isSprinting          | Set animation speed to 7.5
                                    | Set 8Direction maximum speed to 375
    
    System   | Else                 | Set animation speed to [whatever the nromal speed is]
                                    | Set 8Direction maximum speed to 250
    
    System   | Every 0.1 seconds    | Subtract SpritVal from PlayerStamina 
    Player   | isSprinting          |
    [/code:hzw7fx4w]
    
    Hope this helps. Cheers!
  • Sprint val is used for how fast the stamina drains, I dont know what its for when you say playerstamina greater than sprint val. I Redid it with your code and replaced that condition I dont understand with if PlayerStamina is greater than 0, which does the same thing as it did to my code. It drains past 0. I checked in debug if the boolean is being changed and it is, I dont understand why that condition if greater than 0 isnt working.

  • The condition "System | PlayerStamina > SprintVal" means that it will only subtract the SprintVal if theres enough to subtract. If you use "> than 0" PlayerStamina will become -SprintVal. But that's not really important.

    Can you share the capx?

  • The capx is messy and all.. Let me know if you need help finding something.

    https://www.dropbox.com/s/mtgyqwp4buvkg ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey Uglypenguin!

    Found out the problem. You have TWO variables called "PlayerStamina", one is a global variable and the other is a instance variable of Player. You are subtracting SprintVal from the instance variable, but is checking the global variable as a condition for the sprint to work. Note that in your picture the condition "PlayerStamina > 0" is shown with a gear beside it (system variable) while the action "Subtract SprintVal from PlayerStamina" has a dragon beside it (instance variable).

    Here's the fixed capx:

    https://www.dropbox.com/s/uii3ve44ggfrm ... .capx?dl=1

    Hope this helps. Cheers!

  • THANK YOU! I couldnt find what you found!

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