Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C#

No Area to assign sounds

When adding the script to Bird Calls all it shows is that a box with the script in it but no other way to add sounds did I mes the code up?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Collections.Generic;

public class RandomSoundPlayer : MonoBehaviour {

    private AudioSource audioSource;
    [SerializeField]
    private List<AudioClip> soundClips = new List<AudioClip>();
    [SerializeField]
    private float soundTimerDelay = 3f;
    private float soundTimer;


    // Use this for initialization
    void Start () {

        AudioSource = GetComponent<AudioSource> ();
    }

    // Update is called once per frame
    void Update () {

        soundTimer = soundTimer + Time.deltaTime;

        if (soundTimer >= soundTimerDelay) {

            soundTimer = 0f;

            AudioClip randomSound = soundClips[Random.Range (0, soundClips.Count)];

            audioSource.PlayOneShot (randomSound);
        }
    }
}