Audio Trigger Question

I made a scene with a type off animated train object going past the main char
I would like to know whats the best way of making this animated object trigger a sound effect when it passes a certain point. I tried making a cube and placed it in the trains path with an audio source attached and sound. I clicked the make trigger button and attached a script but it didnt work. heres the script i got from the forums

function OnTriggerEnter (other : Collider)




function OnTriggerExit (other : Collider)




thank you


You may have two possible problems:

1- Your train isn’t a CharacterController or Rigidbody, and thus isn’t being detected by the trigger. If this is true, add a rigidbody to your train. If you don’t use the rigidbody to anything else, disable Use Gravity and freeze all rotations and movements in Constraints (both in Rigidbody, at the Inspector) - this will avoid any disturbing physics reaction.

2- The audio source is too far from the audio listener (at the camera, usually), what fades the sound too much to be heard: it’s better to attach the sound and the script to your train, in order to take advantage of the builtin roll off and Doppler effects (the trigger event is sent to the trigger and the object). Add an AudioSource and attach the above script to your train, then create your cubic trigger and size it to the covered area. Adjust the Roll Off curve and the Doppler effect amount to have a more compatible effect.