- Home /
How do you set up a trigger animation without going through the collider?
Hi, i am trying to create a simple trigger animation by having my player collide with the GameObject's Collider, therefore causing the GameObject to do its animation. I set it up so that the animation type is 2 and is legacy, and I tagged my FirstPersonControl "Player". For some reason, though, when I set my collider to "Is Trigger", I go through it and the animation doesn't even play. But when I uncheck the "Is Trigger", I DO collide with the collider, but the animation still does not play. Here is the script if you think thats the problem.
var doorClip : AnimationClip;
function OnTriggerEnter (player : Collider) {
if(player.tag=="Player")
GameObject.Find("Room1_PrisonCellDoor").animation.Play("DoorOpen");
}
Specifically, i'm creating a prison-themed area and I want my prisoner to be able to walk to the PrisonCellDoor, and it opens. Thanks for any advice/help.
What is this script attached to? Do you have errors enabled in your debug console? Are you sure "GameObject.Find("Room1_PrisonCellDoor") is returning a valid game object? Have you put a Debug.break() or Debug.Log() statement in to verify you are entering the "tag==Player" code? Does your prison door have a rigid body assigned (would be bad I think)? If you have isTrigger deselected, OnTriggerEnter will not get called, but OnCollisionEnter will get called. If isTrigger is selected, the opposite is true (it took me a while to realize this).
Your answer
Follow this Question
Related Questions
Destroy trigger so animation only plays once. 1 Answer
Having a door dissapear once a key is collected 1 Answer
Trouble getting a trigger to activate an animation 2 Answers
Animation not playing but trigger works 1 Answer
How do i make a text box appear on screen after a chest has been opened? 3 Answers