# How do I make the game "remember" what direction the sprite was facing before?

Attention Topic was automatically imported from the old Question2Answer platform.

I’m making a game inspired by early Paper Mario.

In those games, you control flat 2-D sprites in 3d environments, and your character can only face four directions: forward left, forward right, backward left, backward right.

When you stop walking, the game remembers which direction you last walked in, so that if you just go forward without tilting left or right, your character will face left or right while walking forward, depending on whichever one you last walked in.

Or if you walk left without tilting either forward or backward, your character will automatically face forward or backward, depending on whichever one you last walked in.

How do I do that?

you would probably use an enum.

Millard | 2020-11-05 04:13

var direction = Vector2.ZERO
const UP = Vector2(0, -1)
const DOWN = Vector2(0, 1)
const RIGHT = Vector2(1, 0)
const LEFT = Vector2(-1, 0

if Input.is_action_pressed(“ui_up”):
direction = UP

``````	elif Input.is_action_pressed("ui_down"):
direction = DOWN

elif Input.is_action_pressed("ui_right"):
direction = RIGHT

elif Input.is_action_pressed("ui_left"):
direction = LEFT
``````