Moving with code is not working

Godot Version

extends CharacterBody2D

const SPEED = 100

func input(event):
var direction = position.x
if event.is_action_pressed(“move_left”):
direction = -1
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)

move_and_slide()

Question

I wanted to know why when i press the move_left action, my character does not move at all from side to side

You’re missing an underscore in the function name

func _input(event):
1 Like

Also, your should use _physics_process instead the _input.

1 Like