Triggering animation in character OnTriggerEnter?

Triggering animation in character OnTriggerEnter?

I've been stuck on this for hours. 
I have a character whose animations are based in mecanim to transition based on the bool variable ShivaEnter. One invisible cube is set to change the bool value from false to true and vice-versa OnTriggerEnter. 
The code is as follows:
using UnityEngine;
using System.Collections;

public class PontyAnimations : MonoBehaviour {

  //[SerializeField]
  private Animator animator;
  //private GameObject ponty;
  //private GameObject ponty;

  void Awake () {
    animator = GetComponent ();
  }

  void OnTriggerEnter (Collider other) {
    if (other.gameObject.tag == "Player") {
      animator.SetBool ("ShivaEnter", true);
    }
  }

  void OnTriggerExit (Collider other) {
    if (other.gameObject.tag == "Player") {
      animator.SetBool ("ShivaEnter", false);
    }
  }
}

Solutions/Answers:

Answer 1:

I changed the code as following and edited the transitions to be more sudden! It worked.

using UnityEngine;
using System.Collections;

public class boxponty : MonoBehaviour {

  public bool ShivaEnter;
  private GameObject player;
  private Animator anim;
  private AudioClip pontysound;

  // Use this for initialization
  void Start () {
  }

  // Update is called once per frame
  void Update () {
    anim = GetComponent<Animator>();
  }

  void OnTriggerEnter (Collider other){
    anim.SetBool ("ShivaEnter", true);
    GetComponent<AudioSource>().Play();
  }

  void OnTriggerExit (Collider other){
    anim.SetBool ("ShivaEnter", false);
  }
}

References