Реализация случайной высоты звука (в том числе и для звуков ходьбы).

This commit is contained in:
Евгений Титаренко 2024-08-17 17:30:36 +03:00
parent 7ca54bdb38
commit fec3f22665
3 changed files with 8 additions and 0 deletions

View file

@ -14,6 +14,9 @@ public partial class AudioCollection : Node
[Export] public bool Shuffle = false;
[Export] public double Timeout = 0;
[Export] public bool RandomPitch;
[Export] public float PitchStart;
[Export] public float PitchEnd;
private State _state;
@ -66,6 +69,7 @@ public partial class AudioCollection : Node
{
case State.Ready:
var player = GetChild<AudioStreamPlayer>(_currentChild);
player.PitchScale = RandomPitch ? _rng.RandfRange(PitchStart, PitchEnd) : 1;
player.Play();
_state = State.Playing;
_currentChild = Shuffle ? _rng.RandiRange(0, _count) : 0;