- Home /
Question by
mcsanquinario · Jun 19, 2019 at 02:38 AM ·
animatortriggermissingcomponentexception
missingcomponentexception even tho there is an animator attached to trigger
i have done this code
public class animating : MonoBehaviour
{
public Animator anim;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
}
public void OnTriggerEnter(Collider other)
{
if (true)
{
anim.Play("knockdown_A");
}
}
}
But even tho when i attach the animator to the gameobject and hit play, it will just uncheck when it triggers, i have been trying to solve this for hours now
Comment
Do you attach the Animator
to the gameObject holding this animating
script??
I advise you to get rid of the anim = GetComponent<Animator>()
in the Start
function and to simply drag & drop the gameObject holding the animator in the anim
field of the inspector.
Your answer
