The problem is for me is that I have the correct code and I set it up right, but it won’t turn visible again. It can go invisible, but can’t go visible again.
using UnityEngine;
using System.Collections;
public class Ammo : MonoBehaviour
{
public float WaitTime;
public GameObject Ammo_Box;
private int Count_Ammo;
// Use this for initialization
void Start()
{
StartCoroutine("MoreAmmo");
Count_Ammo = 0;
}
// Update is called once per frame
public void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
this.gameObject.SetActive(false);
}
}
IEnumerator MoreAmmo()
{
if (Ammo_Box)
{
yield return new WaitForSeconds(WaitTime);
Ammo_Box.SetActive(false);
yield return new WaitForSeconds(WaitTime);
Ammo_Box.SetActive(true);
}
}
}
I don’t know what it is going wrong. I am also trying to create a if statement so when it it triggered and goes invisible, I want the counter to start and after the time is up, then goes visible again.