Hi I'm new in programming and I kinda wanna know how to use 2 Directional Sprite in a Top Down Game which gives a 4 or 8 direction controls.
I'm using this code to move my character but the things is I don't know how to animate with only 2 Direction Sprite. Thank you!
func _physics_process(delta):
move_state(delta)
func move_state(delta):
var input_vector = Vector2.ZERO
input_vector.x = Input.get_action_strength("ui_right") - (Input.get_action_strength("ui_left"))
input_vector.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
input_vector = input_vector.normalized()
if input_vector != Vector2.ZERO:
velocity = velocity.move_toward(input_vector * MAX_SPEED, ACCELERATION * delta)
print(velocity)
else:
velocity = velocity.move_toward(Vector2.ZERO, FRICTION * delta)
move()
func move():
velocity = move_and_slide(velocity)