Does anyone know how to make jumping on a timer/automatic jumping using gdscript

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Alfadog

This is my movement code

extends KinematicBody2D

export (int) var speed = 1200
export (int) var jump_speed = -1800
export (int) var gravity = 4000

var velocity = Vector2.ZERO

func get_input():
velocity.x = 0
if Input.is_action_pressed(“right”):
velocity.x += speed
if Input.is_action_pressed(“left”):
velocity.x -= speed

func _physics_process(delta):
get_input()
velocity.y += gravity * delta
velocity = move_and_slide(velocity, Vector2.UP)
if Input.is_action_just_pressed(“jump”):
if is_on_floor():
velocity.y = jump_speed
Thanks in advance

:bust_in_silhouette: Reply From: deaton64

Hi,

Add a timer. Set the timeout. Start it in _ready()

func _on_Timer_timeout() -> void:
    velocity.y = jump_speed
    $Timer.start()