Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | blackatdz |
Hello, so im making a simple 2d platformer, But I have and issue getting my character to move left, im using the “lerp” function to stop the character’s movement when left or right keys are released moving right works like a charm, but i can’t get my character to move left, it only moves when i hit the key repeatedly.
here’s the code:
extends KinematicBody2D
var velocity = Vector2(0,0)
func _physics_process(delta):
if Input.is_action_pressed("right"):
velocity.x = 100
if Input.is_action_just_pressed("left"):
velocity.x = -100
move_and_slide(velocity)
velocity.x = lerp(velocity.x,0,0.1)