Animation now starting when i want it to.

Hi, i have a problem. I made an animation (just a simple animation where a cube slides up and then down) and i made a script where it activates if the player enters the trigger.

Here is the script.

var Door : GameObject; 

function OnTriggerEnter (other : Collider) 
	{ 
	var contact : String = other.transform.name; 

	if (contact == "Player") 
	{ 
	Door.animation.Play("doorAnimation");
	}
}

So i put a collider on the door and make it a trigger, but now when i try to walk into it, nothing happends.

And the most fun part of this is that i had it working before, then i did some other stuff in my project (nothing that could affect my animations etc) and it stopped working…

Anyone can give me some help?

Uhm, at first glance I’d say that you should use gameObject.name instead of transform, don’t have Unity here right now so I can’t be sure if that’s the problem :slight_smile:

No, that didn’t work, god this is so anoying, Having something that worked perfectly before and suddenly it dont work at all…

Hmm, i think i fixed it. All i did was to put the script on my player and changed so if the player thouches the door it will find the door and play animation.