- Home /
include audio with animation
how would i make it so that the audio is also triggered when the animation is? thank you
var painting : AnimationClip;
var screamsound : AudioClip;
function OnTriggerEnter (player : Collider){
if (player.tag=="Player")
GameObject.Find("picture1").animation.Play("paint");
}
Comment
Answer by Kiloblargh · Dec 15, 2013 at 08:51 AM
Put it in the next line of code. (I'm surprised you asked before trying that..)
If you wanted the audio clip to play at a specific point in the animation instead of immediately, you can use an animation event to call a function that plays the audio clip.
i have got it working with this, but when i run it, it sounds straight way.
var painting : AnimationClip; var screamsound : AudioClip;
function OnTriggerEnter (player : Collider){
if (player.tag=="Player")
GameObject.Find("picture1").animation.Play("paint");
GameObject.Find("picture1").audio.Play();
Why do you have those two variables if you are using GameObject.Find?
because im not good with code lol, ive got rid of it now