22 lines
485 B
C#
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);
|
|
}
|
|
}
|