if i press left and right key at the same time, positive and negative positions neutralize each other. and character wil stop. i want control like Atari 2600 River Raid movement .
How can i do with Gdscript? thanks.
var speed = 400
var acceleration = 0.1
var velocity = Vector2.ZERO
var input_velocity = Vector2.ZERO
input_velocity.x += 1
input_velocity.x -= 1
input_velocity = input_velocity.normalized() * speed
if input_velocity.length() > 0:
velocity = velocity.linear_interpolate(input_velocity, acceleration)
velocity = Vector2.ZERO
velocity = move_and_slide(velocity)