Hello everyone,
I am trying to have the player be able to walk through a wall (game object) that is set inactive on Awake and then once they walk through it (activating the tigger), I want it to set the Box Collider (attached to the game object) active so they cannot go back through the same wall they just went through.
Here is the script I have
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SetWallInactive : MonoBehaviour
{
[SerializeField] BoxCollider col_wall;
void Awake()
{
col_wall.enabled = false;
}
void OnTriggerEnter(Collider col)
{
if (col.tag == "Player")
{
col_wall.enabled = true;
}
}
}
I was going to try “Destroy(other.gameObject);” to make it so the player wouldn’t be able to go back through as the wall has the box collider on it and is set as “is trigger”. But that is a side note, as it is not even setting the Box Collider active after the player goes through the trigger.
At Awake the level will set the wall inactive as it should but when the player walks through, it does nothing.
Any help is very welcomed, this seemed as an easy thing to do, and it has been a nightmare to figure out.