Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | neogi |
I have written the exact code an online tutorial suggested but the player character only moves right when I press the assigned key but not left. here’s the code:
extends KinematicBody2D
var motion = Vector2(0,0)
const speed = 400
func _physics_process(delta):
if Input.is_action_pressed(“left”) and not Input.is_action_pressed(“right”):
motion.x = -speed
if Input.is_action_pressed(“right”) and not Input.is_action_pressed(“left”):
motion.x = speed
else:
motion.x = 0
move_and_slide(motion)