Audio fade

This commit is contained in:
2026-02-12 22:42:18 -08:00
parent c755485855
commit 9615e1e251
13 changed files with 77 additions and 67 deletions

View File

@@ -49,7 +49,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
#region Exports
[ExportGroup("Movement")]
[Export(PropertyHint.Range, "0, 100, 0.1")]
[Export(PropertyHint.Range, "0, 60, 0.1")]
public float RotationSpeed { get; set; } = 1.5f;
[Export(PropertyHint.Range, "0, 100, 0.1")]
@@ -296,7 +296,6 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
public void OnPhysicsProcess(double delta)
{
PlayerLogic.Input(new PlayerLogic.Input.PhysicsTick(delta));
PlayerLogic.Input(new PlayerLogic.Input.Moved(GlobalPosition, GlobalTransform));
}
public void Equip(EquipableItem equipable)
@@ -700,20 +699,25 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
var transform = Transform;
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 (moveDirection.Length() > 0.25f)
{
var rng = new RandomNumberGenerator();
rng.Randomize();
WalkSFX.PitchScale = rng.RandfRange(0.5f, 1.5f);
if (!WalkSFX.Playing)
WalkSFX.Play();
}
else if (WalkSFX.Playing)
WalkSFX.Stop();
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);
var rng = new RandomNumberGenerator();
rng.Randomize();
WalkSFX.PitchScale = rng.RandfRange(0.5f, 1.5f);
if (!WalkSFX.Playing && !Velocity.IsZeroApprox())
WalkSFX.Play();
else if (Velocity.IsZeroApprox())
WalkSFX.Stop();
MoveAndSlide();
}