Play animation on Trigger

Hey, I am working on a 2D Game, I am new to unity and c#. So the problem is that when an object hits on trigger, the animation has to play. I attached the animator on game object and called it on Object controlling script.
But It says this, should I add any namespace? or what should I do?
Game object with animator is inactive
UnityEngine.Animator:Play (string)

Seeing the error code you posted, I’ll add a simple line and see if it works:

void Update()

        // This is just to avoid an error if ExampleNPC is not set
        // The same could be done with the animator
        if(ExampleNPC == null)  

        ExampleNPC.GetComponent<Animator>().Play("Anim name");