(Solved) Moving a Wall when player is in trigger and press a key

Could someone help me with it’s i would like to move a wall when the player is in the right trigger and press a key

this is what i have now:

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

public class Secret : MonoBehaviour
{
    public GameObject Wall;
    public AudioSource WallFX;


    void OnTriggerStay(Collider other)
    {

        if (other.tag == "Wall")
        {
            if (Input.GetButtonDown("Interaction"))
            {
                WallFX.Play();
                Wall.GetComponent<Animator>().Play("secretroom");
                this.GetComponent<BoxCollider>().enabled = false;
            }
        }
    }
}

I assume this component is on your wall? (that’s the correct place for it). You want to check if it’s the player in the trigger, not the wall. Change line 11 to check for the Player tag.

the this.component refers to the Collider and the Wall.component is the wall .
So if i onderstand it right i need to change void OnTriggerStay(Collider other) to void OnTriggerStay(other.tag == “Player”)?

Thank you,

I did change the tag wall to Player and that works :slight_smile:
Thank you very much

1 Like