Interaction script not working

I’m trying to make a script that will activate an animation and destroy the collider (so it only works once) when e is pressed within a collider but pressing e does nothing I don’t know how to fix it here’s the code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class EI : MonoBehaviour
{
  
  public GameObject Fredolph;



  Animator _buttonAnim;

  void OnTriggerEnter(Collider other)
  {
    if(Input.GetKeyDown(KeyCode.E))
    {
      _buttonAnim.SetBool("Interacted", true);
      
     void DestroyGameObject()
     {
        Destroy(Fredolph);
    }
    }
   
    
  }
    // Update is called once per frame
    void Update()
    {
      

    }

    void Start(){
      _buttonAnim = this.transform.parent.GetComponent<Animator>();
  
}
}
1 Like

OnTriggerEnter is called only once, if you want to detect a button press while triggering, use OnTriggerStay.