This is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Delay : MonoBehaviour {
public GameObject laserBeam;
private float timeWait;
private bool setActiveBool;
void Start () {
StartCoroutine (DelayScript ());
}
IEnumerator DelayScript () {
while (true) {
timeWait = 0.2f;
yield return new WaitForSeconds(timeWait);
if (setActiveBool) {;
laserBeam.SetActive (true);
setActiveBool = false;
}
if (!setActiveBool) {
laserBeam.SetActive (true);
setActiveBool = true;
}
}
}
}