0 votes

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?

in Engine by (16 points)

you would probably use an enum.

1 Answer

0 votes

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.isactionpressed("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
by (21 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.