- Home /
Question by
inderjeet172 · Jan 02, 2017 at 09:17 AM ·
animationanimatortriggerball
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
Comment
Answer by AurimasBlazulionis · Jan 02, 2017 at 09:33 AM
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
You clearly missed my point. You have to use other, not ball or ballanim. Well you can use anything as long as it is named as the OnTriggerEnter parameter.
Answer by inderjeet172 · Jan 03, 2017 at 11:47 AM
[link text][1]
Please check this video.. [1]: https://www.youtube.com/watch?v=7dgHt2TO_7U
Your answer
The Animator is Still Enabled.