- Home /
Play animation OnTriggerEnter (C#)
I've never got my head around this but I play animation through a script. so it writes to the console but doesn't play an animation.
using UnityEngine;
using System.Collections;
public class DoorTrig : MonoBehaviour {
public GameObject door;
void OnTriggerEnter (Collider other)
{
if(other.name == "FPSController")
{
door.GetComponent<Animation>().Play("DoorOpen"); //Should play the animation
Debug.Log("Now the animation clip should play");
}
}
}
Hi, is the animation clip attached in the Animation component in "Animation" and "Animations" (List)?
Answer by chesterhilly · Aug 20, 2016 at 02:45 PM
Heres the Solution: http://answers.unity3d.com/questions/1230808/play-animation-ontriggerenter-c.html
Thanks to danivdwerf:
http://answers.unity3d.com/users/845079/danivdwerf.html
give him a follow
Your answer
Follow this Question
Related Questions
How do I ignore trigger objects for collision? 0 Answers
Why isn't OnTriggerEnter() called in the beginning of the game? 1 Answer
Play animation OnTriggerEnter (C#) 1 Answer
OnTriggerEnter/OnCollisionEnter and 5.0 3 Answers
Model has Animator, how do I force start an animation, and tell where it is? (C#) 1 Answer