I’m developing a small game for Hololens through unity and i’m having trouble on how to use my flamethrower effect.
as for now i tried activating the prefab after the onTap event but then it stay enabled once and for all.
I tried activating the prefab and deactivating it but it doesn’t work. I also tried using a coroutine that takes a boolean that activates the prefab accordingly to the boolean value.
the code is something like this
public void Start()
{
StartCoroutine(onOff(state));
}
public void OnInputClicked(InputClickedEventData eventData)
{
onOff(!state);
GameManager.Instance.score++;
if (GameManager.Instance.score > GameManager.Instance.highScore)
GameManager.Instance.highScore = GameManager.Instance.score;
state = false;
}
IEnumerator onOff(bool s)
{
if (s)
{
flare.SetActive(s);
yield return new WaitForSeconds(1f);
flare.SetActive(!s);
s = false;
state = false;
}
}
i’m really is not sure about the coroutine itself.
Any suggestion is well accepted.