I am trying to have something repetitively simple happen, I want the player to be able to walk through a wall with the BoxCollider set inactive, and once they pass though the collider, i want the BoxCollider to be set active and not allow them to go back though it. I have tried a few different combinations, not sure if I should use SetActive or .enabled and I am thinking that OnColissionEnter will do the trick because the wall is thin, but OnCollisionExit may be better.
I just need a little help with this problem as I cannot seem the write the correct C# code that solves my problem.
Here is what I have
using UnityEngine;
using System.Collections;
public class SetWallInactive : MonoBehaviour
{
Private Void OnCollisionEnter(other)
{
If (other.tag = “Player”)
{
this.GetComponent<BoxCollider>().enabled = false;
}
}
}
thank you for any help you can offer.