I need to activate a sound clip when my first person controller drops an object with a box collider and rigid body onto another object with a box collider. any suggestions as to how i would achieve this?
asked Nov 10 '10 at 07:26 AM
There are these two things you want:
The condition being: A collision between 2 box colliders The reaction being : Play a sound file
These are actually 2 questions, do you have trouble with playing sound or detecting collisions or both?
Here's some suggestions that assume the worst case scenario:
Your collision response could come from a trigger by objects carrying tag properties
Another idea may be to have the rigidbody of each object check for collisions (which the physics engine does ) catch the message using the suggestion spree just handed you and when you caugth the collision message you can use the same reaction you would in situation 1.
To play an audio file you will need to attach it to the object probably, and since collisions between different objects cause different sounds both objects should play the sounds maybe, up to you I guess what you want to hear.
To play sound, load the sound into a public variable with the type AudioSource
answered Nov 10 '10 at 03:14 PM
use OnCollisionEnter. You could attach an audiosource with the correct audioclip to your object and then OnCollisionEnter do audio.Play();
answered Nov 10 '10 at 08:47 AM