controller support wip

pull/6/head
John Montagu, the 4th Earl of Sandvich 2023-08-12 23:18:12 -07:00
parent 8e7750111b
commit 236e21c7c9
Signed by: sandvich
GPG Key ID: 9A39BE37E602B22D
1 changed files with 10 additions and 1 deletions

View File

@ -50,6 +50,8 @@ public abstract partial class PlayerState : CharacterState
Vector2 mousePos = Character.GetGlobalMousePosition(); Vector2 mousePos = Character.GetGlobalMousePosition();
Vector2 dirToMouse = Character.GlobalPosition.DirectionTo(mousePos); Vector2 dirToMouse = Character.GlobalPosition.DirectionTo(mousePos);
Vector2 joystick = Godot.Input.GetVector("look_left", "look_right",
"look_up", "look_down");
if (Character.Inventory.SelectedItem is Items.Weapon weapon) if (Character.Inventory.SelectedItem is Items.Weapon weapon)
{ {
@ -58,7 +60,14 @@ public abstract partial class PlayerState : CharacterState
if (!weapon.ShouldHideIdle || isAttack1On) if (!weapon.ShouldHideIdle || isAttack1On)
{ {
Character.Target = dirToMouse; if (joystick.IsZeroApprox())
{
Character.Target = Character.Direction;
}
else
{
Character.Target = joystick;
}
} }
if (isAttack1On) if (isAttack1On)