Basic Movement

PHOTO EMBED

Mon Mar 14 2022 11:33:58 GMT+0000 (Coordinated Universal Time)

Saved by @TheEmptySet #gdscript #godot

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)	
content_copyCOPY

BornCG - Lets Build A 2D Platformer Tutorial

https://www.youtube.com/watch?v=oAb_Ju33fqU