Im trying to pick a random sound picked from an array, then make the AudioSource become that sound. I cant figure out what Im doing wrong D;
Script: (C#)
using UnityEngine;
using System.Collections;
public class randomSound : MonoBehaviour {
public AudioClip[] ricochet; // The array controlling the sounds
public int rayMax; // The max amount of Sounds there are
public int pickedSound; // The sound is choose to play
// Use this for initialization
void Start () {
pickedSound = Random.Range(0, rayMax); // Grab a random sound out of the max
gameObject.GetComponent<AudioSource>.clip = ricochet[pickedSound]; // Tell the AudioSource to become that sound
}
// Update is called once per frame
void Update () {
}
}
ERROR:
Assets/Game/FX/randomSound.cs(12,28): error CS0119: Expression denotes a method group', where a variable’, value' or type’ was expected