How do I destroy an object with a trigger?

I’m trying to have a player walk over a pressure plate trigger and have that cause a door to destroy itself, but I can’t figure out the code for it. I’m also really new to Unity, and programming in general, so I think I’m trying to do something out of my skill set. The two ways I’ve tried are:

else if( == “PressurePlate6”) { Destroy(“Lockout”)); } else if( == “PressurePlate7”) { GameObject(“BoulderTrapDoor”).isCollider = false; }

To what is this script attached, I assume the player?

If you need to destroy an object named “Lockout”, make a public variable outside the function, and assign the door’s gameobject to it via the Inspector.
public GameObject lockoutDoor;

and then within your function:

Same with the drapdoor object. Use as much Inspector assigning where possible. Otherwise, try to find all the gameObject within your “Start” function, and in Update only access the saved objects.

Hi, first off this site is great for getting better with programming you’ll be fine after a few months of experience.

Okay, this is how I would do it.

  1. Tag your player with “Player”.

  2. Make sure the player is NOT set to IsTrigger.

  3. Put this script on your PressurePlate.

    public GameObject door; // This is where you reference the door you want to destroy

    void OnCollisionEnter(Collision other) {

    if(other.tag == “Player”) {
    Destroy(gameObject); //This will destroy the pressure plate after it has been triggered