The idea is that when a gameobject enters an empty gameobject’s box collider, it will play a sound. However I am struggling to even detect collisions between the two objects!
Here is the setup of the empty game object:
And here is the gameobject which is colliding with it:
This is the code I am using for detecting collisions:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(AudioSource))]
public class playEricSound : MonoBehaviour {
public AudioClip eric;
void OnCollisionEnter2D (Collision2D collide) {
print ("Collide");
audio.PlayOneShot(eric);
}
}
Thanks for your help! If you need anything else, just ask!