I'm fairly new to Godot. I have copied a code from a project to a new one, but it didnot work.

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

extends KinematicBody2D

the game works as a loop, it runs 30 - 60 times per second

#it runs all he code inside process function

var input_direction = 0
var direction = 0 # integer (move right and left ) #last direction
var speed = 0
const MAX_SPEED = 30000
const ACCELERATION = 10000
const DECELERATION = 20000
var velocity = 0

func _ready() : # first function the engine will look at
set_process(true) # to say set this script to Process at each frame, each single frame the code will b
pass # prevents the parsing errors

func _process(delta): #Delta: the time interval between two rendered frames
#input
if input_direction: #to not set direction to 0
direction = input_direction

if Input.is_action_pressed("ui_left"): #left arrow
	input_direction = -1
elif Input.is_action_pressed("ui_right"): #right arrow
	input_direction = 1
else : #no keyes pressed
	input_direction = 0 

#Movement	
if input_direction == - direction: # to slow down when it changes direction 
	speed /= 3
	
if input_direction:
	speed += ACCELERATION * delta
else:
	speed -= DECELERATION * delta
	
speed = clamp(speed,0, MAX_SPEED) #restrict the speed b/w 0 and MAX speed
	
velocity = speed * delta * direction
move_and_slide(Vector2(velocity,0))
pass

What is the problem exactly?

SteveSmith | 2022-11-16 10:00