- Home /
How to make animations only play with script?
Hello! I've recently run into a animation problem. I'm trying to make a door open when you enter a trigger, so I made a very simple animation of the door opening to activate with the script. The problem is - the animation just plays automatically when the scene starts up. I did the animation just with the unity basic animator, and I looked into the settings to see if I could make it only play when I tell it to, but I had no luck. What am I doing wrong? Is it my script? This is what I wrote: var doorSound : AudioClip; var doorObject : GameObject;
function OnTriggerEnter (col : Collider) {
if(col.gameObject.tag == "Player") {
AudioSource.PlayClipAtPoint(doorSound, transform.position);
doorObject.animation.Play();
Destroy(gameObject);
}
}
What do I need to do? Thank you in advance for your help! :D
Answer by Darwin Mecharov · Apr 09, 2014 at 02:22 AM
Did you make sure to uncheck "Play Automatically" in the Animation component on the Inspector?