HOW TO FACE THE PLAYER SPRITE LEFT WHEN PRESS LEFT

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Hridoy

const GRAVITY = 200.0
const WALK_SPEED = 100

var velocity = Vector2()

func _physics_process(delta):
velocity.y += delta * GRAVITY

if Input.is_action_pressed("ui_left"):
	velocity.x = -WALK_SPEED
elif Input.is_action_pressed("ui_right"):
	velocity.x = WALK_SPEED
else:
	velocity.x = 0
if Input.is_action_just_pressed("ui_up"):
	velocity.y = -WALK_SPEED
move_and_slide(velocity, Vector2(0, -1))
:bust_in_silhouette: Reply From: jgodfrey

There are a number of ways to accomplish this. Choosing the best way depends on a number of things, including the organization of your scene tree and the node types in question. A few options might be to:

  • Simply flip the sprite via its flip_h property
  • Flip the X component of the scale between 1 and -1 depending on required direction

There are other possibilities as well. See this question and some of the answers for additional details.

https://forum.godotengine.org/3953/want-flip-character-the-horizontal-axis-but-whats-the-best-way

thankyou so much

Hridoy | 2022-03-11 16:51