Unity Under 3 - Randomize Audio

Опубликовано: 13 Июль 2026
на канале: Flip the Switch Education
100
2

In this video, you'll learn how to write a simple C# script that plays a random audio clip from an array of clips in Unity. You'll create a public AudioClip array and add an AudioSource component to your game object. Then, you'll use the GetComponent method to find the audio source, and create a public method that checks for audio clips in the array, selects a random index, sets the selected clip as the clip to be played, and calls the Play method to play the clip. By the end of the video, you'll have a working PlayRandomAudio script that can play random audio clips in your Unity game.