Player looks in last direction; fix #17
parent
17104e7b74
commit
88c296dd13
|
@ -130,7 +130,14 @@ public partial class Character : CharacterBody2D, IFaction
|
|||
StunAnimation.Stop();
|
||||
}
|
||||
|
||||
Sprite.FlipH = Target.X < 0;
|
||||
if (Target.X < 0)
|
||||
{
|
||||
Sprite.FlipH = true;
|
||||
}
|
||||
else if (Target.X > 0)
|
||||
{
|
||||
Sprite.FlipH = false;
|
||||
}
|
||||
DrawTarget();
|
||||
}
|
||||
|
||||
|
@ -214,7 +221,7 @@ public partial class Character : CharacterBody2D, IFaction
|
|||
scale.Y = -1;
|
||||
angle = Mathf.Pi - angle;
|
||||
}
|
||||
else
|
||||
else if (target.X > 0)
|
||||
{
|
||||
scale.Y = 1;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,20 @@ public sealed partial class Player : Character
|
|||
{
|
||||
private string _spriteAnim;
|
||||
|
||||
public Vector2 DesiredTarget { get; set; }
|
||||
private Vector2 _desiredTarget;
|
||||
|
||||
public Vector2 DesiredTarget
|
||||
{
|
||||
get => _desiredTarget;
|
||||
set
|
||||
{
|
||||
if (value.IsZeroApprox())
|
||||
{
|
||||
return;
|
||||
}
|
||||
_desiredTarget = value;
|
||||
}
|
||||
}
|
||||
|
||||
[Export]
|
||||
public PlayerCamera Camera { get; set; }
|
||||
|
|
|
@ -56,7 +56,12 @@ public abstract partial class PlayerState : CharacterState
|
|||
Character.LookTowardsDirection();
|
||||
|
||||
var player = _player;
|
||||
player.DesiredTarget = player.GetDesiredInputFromInput();
|
||||
var desiredTarget = player.GetDesiredInputFromInput();
|
||||
if (!desiredTarget.IsZeroApprox())
|
||||
{
|
||||
// can never be zero
|
||||
player.DesiredTarget = desiredTarget;
|
||||
}
|
||||
|
||||
if (Character.Inventory.SelectedItem is Items.Weapon weapon)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue