Fix some control issues
This commit is contained in:
@@ -102,6 +102,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
|
||||
private bool _healthTimerActive = true;
|
||||
|
||||
private bool _debugSprint = false;
|
||||
|
||||
private float _knockbackStrength = 0.0f;
|
||||
private Vector3 _knockbackDirection = Vector3.Zero;
|
||||
|
||||
@@ -242,9 +244,9 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
if (@event.IsActionPressed(GameInputs.Attack))
|
||||
Attack();
|
||||
if (@event.IsActionPressed(GameInputs.Sprint))
|
||||
Settings.MoveSpeed *= 2;
|
||||
if (@event.IsActionReleased(GameInputs.Sprint))
|
||||
Settings.MoveSpeed /= 2;
|
||||
_debugSprint = true;
|
||||
else if (@event.IsActionReleased(GameInputs.Sprint))
|
||||
_debugSprint = false;
|
||||
}
|
||||
|
||||
public void PlayTestAnimation()
|
||||
@@ -350,6 +352,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
|
||||
transform.Basis = new Basis(Vector3.Up, Settings.RotationSpeed * -rawInput.X * delta) * transform.Basis;
|
||||
var moveDirection = new Vector3(strafeRightInput - strafeLeftInput, 0, rawInput.Z).Normalized();
|
||||
var velocity = Basis * moveDirection * Settings.MoveSpeed * Settings.Acceleration;
|
||||
if (_debugSprint)
|
||||
velocity *= 2;
|
||||
_knockbackStrength *= 0.9f;
|
||||
Transform = Transform with { Basis = transform.Basis };
|
||||
Velocity = velocity + (_knockbackDirection * _knockbackStrength);
|
||||
|
||||
Reference in New Issue
Block a user