extends CharacterBody2D const SPEED = 180 const JUMPFORCE = -950 const GRAVITY = 40 func _physics_process(delta): if Input.is_action_pressed("right"): velocity.x = SPEED if Input.is_action_pressed("left"): velocity.x = -SPEED if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = JUMPFORCE velocity.y += GRAVITY move_and_slide() velocity.x = lerp(velocity.x, 0.0, 0.1)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter