Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | PopSquip |
I want to make a cap for the amount of time the player can jump per second how should i go about doing this?
extends KinematicBody2D
const GRAVITY = 10 # in pixels const
JUMP = 25 # start speed px/s
const SPEED = 480 # px/s var
velocity = Vector2.ZERO # (0,0)
func _ready():
pass func _on_Timer_timeout():
print(str($Timer.wait_time) + " second(s) finished")
func _physics_process(delta): # if no keyboard input for left/right then x speed is 0 velocity.x = 0
if(Input.is_action_pressed(“right”)): velocity.x = SPEED
elif(Input.is_action_pressed(“left”)):
velocity.x = -SPEED velocity.y += GRAVITY if (Input.is_action_just_pressed(“jump”)):
velocity.y -= 250 velocity = move_and_slide(velocity)
Your sample code is hard to read because you did not format it properly.
wyattb | 2021-06-08 01:49