Hi UnityAnswers,
I am trying to play a sound when the player walks into the cube? At the moment the game crashes when the player collides with the cube?
Any ideas, help, suggestions would be appreciated.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Trigger : MonoBehaviour
{
public GameObject guiObject;
private Question1 guiScript;
public AudioSource collision;
void Awake ()
{
guiScript = guiObject.GetComponent<Question1> ();
guiScript.enabled = false; //Turn off the script, so the OnGUI function doesn't draw the question window
}
void OnTriggerEnter (Collider other)
{
if (collision)
audio.Play();
guiScript.enabled = true;
Destroy (this.gameObject);
}
}