RiftMayhem/Assets/Audio/Scripts/PitchRandomizer.cs
2025-06-08 12:18:13 +01:00

22 lines
485 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class PitchRandomizer : MonoBehaviour
{
[Range(0f, 0.1f)]
[SerializeField] private float pitchDeviationRange;
AudioSource source;
private void Awake()
{
source = GetComponent<AudioSource>();
}
public void RandomizePitch()
{
source.pitch = 1 + Random.Range(-pitchDeviationRange, pitchDeviationRange);
}
}