mecanim animation transition script


I’m using mecanim and trying to trigger a transition from one animation state to another. I have set up a trigger parameter (should I be using bool?), and would like to trigger the transition between the states when a collider is entered. I have colliders on my character, and the colliding game object. The script runs without errors, it just doesn’t work. Here’s the code I have so far:

using UnityEngine;
using System.Collections;

public class Strike_Tower : MonoBehaviour 
	Animator anim;
	void Start(){
		anim = GetComponent<Animator>();
	void OnTriggerEnter(Collider other) 
		if(other.transform.tag == "Tower")


Any thoughts?



Are you using a 2D collider?
Is collider on the same object as the animator?

You should be using code to set a parameter, not a trigger in the anim. For Instance, if your mecanim system has a bool called triggering, then you would use anim.SetBool("triggering", true);. Then you would have a transition in your mecanim system when that bool is set to true.

edit__ after reading more about Triggers, they seem to work like booleans except that are set to inactive after they happen. In that case, have you set up a transition to happen when the parameter becomes true?

I was just missing a rigid body collider on my character… duh. Thanks all.