Fixed Vesna sliding issue

pull/10/head
kziolkowski 6 months ago
parent 7467ec56d9
commit bcdba7b812

@ -44,42 +44,52 @@ public partial class Player2D : CharacterBody2D
if (!_canHandleInput) if (!_canHandleInput)
return; return;
if (Input.IsActionPressed("move_right")) bool right = Input.IsActionPressed("move_right");
bool left = Input.IsActionPressed("move_left");
bool up = Input.IsActionPressed("move_up");
bool down = Input.IsActionPressed("move_down");
bool walkingAnimationPicked = false;
if (up)
{ {
Velocity = new Vector2(_speed, 0); Velocity = new Vector2(0, -_speed);
MoveAndSlide(); MoveAndSlide();
_sprite.FlipH = false; _sprite.Animation = "back walking" + _toolString;
_sprite.Animation = "side walking" + _toolString;
anyActionPressed = true; anyActionPressed = true;
_lastDirection = Vector2.Right; _lastDirection = Vector2.Up;
walkingAnimationPicked = true;
} }
if (Input.IsActionPressed("move_left")) if (down && !walkingAnimationPicked)
{ {
Velocity = new Vector2(-_speed, 0); Velocity = new Vector2(0, _speed);
MoveAndSlide(); MoveAndSlide();
_sprite.FlipH = true; _sprite.Animation = "front walking" + _toolString;
_sprite.Animation = "side walking" + _toolString;
anyActionPressed = true; anyActionPressed = true;
_lastDirection = Vector2.Left; _lastDirection = Vector2.Down;
walkingAnimationPicked = true;
} }
if (Input.IsActionPressed("move_up")) if (right && !walkingAnimationPicked)
{ {
Velocity = new Vector2(0, -_speed); Velocity = new Vector2(_speed, 0);
MoveAndSlide(); MoveAndSlide();
_sprite.Animation = "back walking" + _toolString; _sprite.FlipH = false;
_sprite.Animation = "side walking" + _toolString;
anyActionPressed = true; anyActionPressed = true;
_lastDirection = Vector2.Up; _lastDirection = Vector2.Right;
walkingAnimationPicked = true;
} }
if (Input.IsActionPressed("move_down")) if (left && !walkingAnimationPicked)
{ {
Velocity = new Vector2(0, _speed); Velocity = new Vector2(-_speed, 0);
MoveAndSlide(); MoveAndSlide();
_sprite.Animation = "front walking" + _toolString; _sprite.FlipH = true;
_sprite.Animation = "side walking" + _toolString;
anyActionPressed = true; anyActionPressed = true;
_lastDirection = Vector2.Down; _lastDirection = Vector2.Left;
walkingAnimationPicked = true;
} }
if (Input.IsActionPressed("interact2")) if (Input.IsActionPressed("interact2"))

Loading…
Cancel
Save