Strafing
This commit is contained in:
@@ -16,6 +16,10 @@ namespace GameJamDungeon
|
||||
PlayerData PlayerData { get; }
|
||||
|
||||
public Vector3 GetGlobalInputVector();
|
||||
|
||||
public float GetLeftStrafeInputVector();
|
||||
|
||||
public float GetRightStrafeInputVector();
|
||||
}
|
||||
|
||||
[Meta(typeof(IAutoNode))]
|
||||
@@ -139,8 +143,7 @@ namespace GameJamDungeon
|
||||
|
||||
public override void _UnhandledInput(InputEvent @event)
|
||||
{
|
||||
var attackIsPressed = Input.IsActionJustPressed(GameInputs.Attack);
|
||||
if (attackIsPressed && !GameRepo.IsWithinDialogueSpace)
|
||||
if (Input.IsActionJustPressed(GameInputs.Attack))
|
||||
PlayerLogic.Input(new PlayerLogic.Input.Attack());
|
||||
}
|
||||
|
||||
@@ -176,7 +179,6 @@ namespace GameJamDungeon
|
||||
public Vector3 GetGlobalInputVector()
|
||||
{
|
||||
var rawInput = Input.GetVector(GameInputs.MoveLeft, GameInputs.MoveRight, GameInputs.MoveUp, GameInputs.MoveDown);
|
||||
|
||||
var input = new Vector3
|
||||
{
|
||||
X = rawInput.X,
|
||||
@@ -185,6 +187,18 @@ namespace GameJamDungeon
|
||||
return input with { Y = 0f };
|
||||
}
|
||||
|
||||
public float GetLeftStrafeInputVector()
|
||||
{
|
||||
var leftStrafe = Input.GetActionStrength(GameInputs.StrafeLeft);
|
||||
return leftStrafe;
|
||||
}
|
||||
|
||||
public float GetRightStrafeInputVector()
|
||||
{
|
||||
var rightStrafe = Input.GetActionStrength(GameInputs.StrafeRight);
|
||||
return rightStrafe;
|
||||
}
|
||||
|
||||
public void ThrowItem()
|
||||
{
|
||||
var itemScene = GD.Load<PackedScene>("res://src/items/throwable/ThrowableItem.tscn");
|
||||
|
||||
@@ -16,10 +16,12 @@ namespace GameJamDungeon
|
||||
var settings = Get<Settings>();
|
||||
|
||||
var rawInput = player.GetGlobalInputVector();
|
||||
var strafeLeftInput = player.GetLeftStrafeInputVector();
|
||||
var strafeRightInput = player.GetRightStrafeInputVector();
|
||||
|
||||
var transform = player.Transform;
|
||||
transform.Basis = new Basis(Vector3.Up, settings.RotationSpeed * -rawInput.X) * transform.Basis;
|
||||
var velocity = player.Basis * new Vector3(0, 0, rawInput.Z) * settings.MoveSpeed;
|
||||
var velocity = player.Basis * new Vector3(strafeRightInput - strafeLeftInput, 0, rawInput.Z) * settings.MoveSpeed;
|
||||
|
||||
if (Godot.Input.IsActionPressed(GameInputs.Sprint))
|
||||
velocity *= 3;
|
||||
|
||||
Reference in New Issue
Block a user