title: Animating a child object in unity
body: <p>I have this table drawer I am trying to animate, where if the player presses "E", the drawer opens and stays open. And when the player presses "E" again, the door closes. 
  The script is based on the player entering a trigger and I have it on multiple doors in my scene.
   I'm running into a few issues though, with the drawer when the player presses "E" the collider on the door moves but the drawer gameObject does not. 
  I have come to the conclusion that it's not script because its working finds on the doors, but I have tried everything else. I will attach some images for reference.</p>
  
  <pre><code>public class DoorScript : MonoBehaviour
  {
  
  public GameObject OpenPanel = null;
  
  private bool _isInsideTrigger = false;
  
  public Animator _animator;
  
  public string OpenText = "Press 'E' to open";
  
  public string CloseText = "Press 'E' to close";
  
  private bool _isOpen = false;
  
  private void Start()
  {
      OpenPanel.SetActive(false);
  }
  
  
  void OnTriggerEnter(Collider other)
  {
      if (other.tag == "Player")
      {
          _isInsideTrigger = true;
          OpenPanel.SetActive(true);
          UpdatePanelText();
      }
  }
  
  private void UpdatePanelText()
  {
      Text panelText = OpenPanel.transform.Find("Text").GetComponent&lt;Text&gt;();
      if (panelText != null)
      {
          panelText.text = _isOpen ? CloseText: OpenText;
      }
  }
  
  void OnTriggerExit(Collider other)
  {
      if (other.tag == "Player")
      {
          _isInsideTrigger = false;
          OpenPanel.SetActive(false);
      }
  }
  
  private bool IsOpenPanelActive
  {
      get
      {
          return OpenPanel.activeInHierarchy;
      }
  }
  
  // Update is called once per frame
  void Update()
  {
      if (IsOpenPanelActive &amp;&amp; _isInsideTrigger)
      {
          if (Input.GetKeyDown(KeyCode.E))
          {
              _isOpen = !_isOpen;
  
              Invoke("UpdatePanelText", 1.0f);
  
              _animator.SetBool("open", _isOpen);
          }
      }
  }
  </code></pre>
  
  <p>}
  //Credit Jayanam Youtube Channel for Script</p>
  
  <p><a href="https://i.stack.imgur.com/b7vtu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b7vtu.jpg" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/40uxg.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/40uxg.jpg" alt="enter image description here"></a></p>