how can I control a animation by a script

Hi,
I want to trigger a game object by a script.
In fact I’ve got a game object with BoxCollider, Rigidbody and Configurable Joint like it was described in the 2D-Game-Tutorial.
Also I’ve allocated an animation to this GameObject.

My FPC has got a BoxCollider too and I thought, when the FPC-Box hits the GameObject-Box the animation will be played - and when the FPC leaves the other Box, the animation will reset or play another animation.

But how to script this?

That’s my try but that’s my first script…

var animationRoot : Animation;

function OnTriggerEnter (col : Collider) 
{
	var controller : FirstPersonController = col.GetComponent(FirstPersonController);
	if (controller != null)
	{
		Animation.clip;
		animationRoot.wrapMode = WrapMode.Once;	
	}
}

Good idea. Go do it :slight_smile:

I frat with the script reference and by now my code is still not working:

var animationRoot : Animation;


function OnCollisionEnter (col : Collision) 
{
animation.Play("HaustuerOpener");
	//animationRoot.wrapMode = WrapMode.Once;
}

The script is attached by the “Haustuer”.