On/Off Animator using script

public Animator ballanim;

     void OnTriggerEnter(Collider other)
	if (other.gameObject.CompareTag("ball") )
		ballanim.GetComponent<Animator>().enabled = false;

actually i want to disable animator of an object using script.the above code is not working

Change line 5 to other.GetComponent<Animator>().enabled = false. Here you go.

If it does not always work, it might be because ball’s child object hits you, not the ball itself, then try other.transform.root.GetComponent<Animator>().enabled = false

[link text][1]

Please check this video…
[1]: - YouTube