Fixed Vesna sliding issue
This commit is contained in:
@@ -44,7 +44,33 @@ 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(0, -_speed);
|
||||||
|
MoveAndSlide();
|
||||||
|
_sprite.Animation = "back walking" + _toolString;
|
||||||
|
anyActionPressed = true;
|
||||||
|
_lastDirection = Vector2.Up;
|
||||||
|
walkingAnimationPicked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (down && !walkingAnimationPicked)
|
||||||
|
{
|
||||||
|
Velocity = new Vector2(0, _speed);
|
||||||
|
MoveAndSlide();
|
||||||
|
_sprite.Animation = "front walking" + _toolString;
|
||||||
|
anyActionPressed = true;
|
||||||
|
_lastDirection = Vector2.Down;
|
||||||
|
walkingAnimationPicked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (right && !walkingAnimationPicked)
|
||||||
{
|
{
|
||||||
Velocity = new Vector2(_speed, 0);
|
Velocity = new Vector2(_speed, 0);
|
||||||
MoveAndSlide();
|
MoveAndSlide();
|
||||||
@@ -52,9 +78,10 @@ public partial class Player2D : CharacterBody2D
|
|||||||
_sprite.Animation = "side walking" + _toolString;
|
_sprite.Animation = "side walking" + _toolString;
|
||||||
anyActionPressed = true;
|
anyActionPressed = true;
|
||||||
_lastDirection = Vector2.Right;
|
_lastDirection = Vector2.Right;
|
||||||
|
walkingAnimationPicked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.IsActionPressed("move_left"))
|
if (left && !walkingAnimationPicked)
|
||||||
{
|
{
|
||||||
Velocity = new Vector2(-_speed, 0);
|
Velocity = new Vector2(-_speed, 0);
|
||||||
MoveAndSlide();
|
MoveAndSlide();
|
||||||
@@ -62,24 +89,7 @@ public partial class Player2D : CharacterBody2D
|
|||||||
_sprite.Animation = "side walking" + _toolString;
|
_sprite.Animation = "side walking" + _toolString;
|
||||||
anyActionPressed = true;
|
anyActionPressed = true;
|
||||||
_lastDirection = Vector2.Left;
|
_lastDirection = Vector2.Left;
|
||||||
}
|
walkingAnimationPicked = true;
|
||||||
|
|
||||||
if (Input.IsActionPressed("move_up"))
|
|
||||||
{
|
|
||||||
Velocity = new Vector2(0, -_speed);
|
|
||||||
MoveAndSlide();
|
|
||||||
_sprite.Animation = "back walking" + _toolString;
|
|
||||||
anyActionPressed = true;
|
|
||||||
_lastDirection = Vector2.Up;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Input.IsActionPressed("move_down"))
|
|
||||||
{
|
|
||||||
Velocity = new Vector2(0, _speed);
|
|
||||||
MoveAndSlide();
|
|
||||||
_sprite.Animation = "front walking" + _toolString;
|
|
||||||
anyActionPressed = true;
|
|
||||||
_lastDirection = Vector2.Down;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Input.IsActionPressed("interact2"))
|
if (Input.IsActionPressed("interact2"))
|
||||||
|
|||||||
Reference in New Issue
Block a user