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?