Hey trying to make to a script for making a wall in my game be set to deactivating it at the start of the game. And upon detection of a bullet passing through it will destroy the bullet & will make the wall become active and appear before disappearing and becoming inactive after specific amount of time.
Code below is what I have so far. How would I go about making it work?
public class AppearingWall : MonoBehaviour
{
// Use this for initialization
void Start()
{
gameObject.SetActive(false);
}
public void OnTriggerEnter(Collider col)
{
int countDown = 0;
if (col.tag == "Bullet")
{
gameObject.SetActive(true);
countDown++;
if (countDown > 5)
{
gameObject.SetActive(false);
}
}
}
}