extends KinematicBody2D var velocity = Vector2(0,0) export var speed : int = 180 export var jumpForce : int = 850 export var gravity : int = 35 func _physics_process(delta): if Input.is_action_pressed("right"): velocity.x = speed if Input.is_action_pressed("left"): velocity.x = -speed velocity.y += gravity if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = -jumpForce velocity = move_and_slide(velocity,Vector2.UP) velocity.x = lerp(velocity.x, 0, 0.3)
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