Welcome to the forums @IgoCigo!
How is the code not working? Is the player not moving correctly, Godot giving an error, or something else?
Based on the code above, the problem is likely indentation, as lines 21
to 26
are not indented by a single tab and therefore will not be interpreted as part of the _physics_process
function. To fix this, you just need to give them a single indent:
extends KinematicBody2D
var velocity = Vector2(0,0)
var coins = 0
const SPEED = 350
const JUMPFORCE = -1100
const GRAVITY = 35
const FRICTION = 1
func _physics_process(delta):
if Input.is_action_pressed("ui_right"):
velocity.x = SPEED
elif Input.is_action_pressed("ui_left"):
velocity.x = -SPEED
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
velocity.y = velocity.y + GRAVITY
if Input.is_action_just_pressed("ui_up") and is_on_floor():
velocity.y = JUMPFORCE
velocity = move_and_slide(velocity,Vector2.UP)
velocity.x = lerp(velocity.x,0,0.2)