Open comments for this post
Sprinting!
took a bit, but I finally got sprinting to work.
Works pretty simply, the characters motion is determined by a speed variable, which just increases if the sprint button (shift) is held down.
Here’s the code:
if Input.is_action_just_pressed(“sprint”) and stamina >= 1:
state_machine.travel(“sprint”)
sprinting_timer.start()
SPEED = 200
sprinting = true
elif Input.is_action_just_released(“sprint”):
SPEED = 75
sprinting = false
sprinting_timer.stop()
I’m using an animation_tree for my animations, instead of just a player, this helps the transitions from animations feel smoother, so thats what the “state_machine” is. The “sprinting” variable is used to force other animations (e.g, for idling and running) to check if the player is sprinting, and thus not override the animation (the sprinting animation currently is identical to running, but when I start designing the character i’ll change that). The timer is just on a .5 sec loop, and makes the stamina decrease when it ends, the second bit of code checks if you stopped sprinting, and returns the SPEED to normal and stops the timer loop.
This code doesn’t actually fully work, as another if statement is needed. The extra “and” in the first check makes sure you can’t start sprinting if stamina is below one, but actually only checks once when you start sprinting, not constantly, so the sprinting doesn’t stop if stamina goes below 1 (like it should).
if stamina < 1:
SPEED = 75
sprinting_timer.stop()
sprinting = false
This code, unlike the first “if”, checks consistantly if stamina’s below one, and does the same job as if you let go of sprinting. This keeps stamina from going negative D:
In the future I plan on adding a gradient to the effect, so the speed up isn’t as jarring, but this is a good start!
Thanks to Brackeys for the current assets! (go watch his video on Godot, it’s very informative)
~wil
Open comments for this post
Finally started to develop a “game”
made 3 things, Attacks, Stamina, and GUI
Attacks:
->use hurtboxes detect if an area entered, if that area is_in_group(“attackarea”) the hurtbox takes a damage variable and applies it to the thing it’s attached too (Player, enemy, etc)
Stamina:
-> A timer slowly makes it tick upwards, starts at 10, and goes down if the player jumps or attacks, uses a Global Variable allow the GUI to display the stamina (there’s probably a better way but I’m lazy ¯_(ツ)_/¯)
GUI:
->uses a canvas layer being displayed over a sub-viewport, which includes the coins and stamina, just displays text and then the quantities of each integer.
next steps:
->destructible blocks
->physics blocks
->stamina bar (not integer)
->sprinting (and smoother movement.
Thanks to Brackeys for the assets!
Open comments for this post
Finally done learning basic Godot!!
My entire time has been dedicated to just learning how to use the software, and I’m glad to say I now have something to work off of. I still need to learn more, like GDscript, pixel art, and game design.
Next Steps!
-develop weapon (sledgehammer :D)
-destructible terrain elements (fancy walls that get destroyed)
-physics blocks
-begin designing character and aliens