public class MuzzleFlash : MonoBehaviour
{
public GameObject flash;
void Update()
{
if (Input.GetMouseButton(0))
{
IEnumerator MyMethod()
{
flash.SetActive(true);
yield return new WaitForSeconds(2);
flash.SetActive(false);
}
}
{
}
}
}
public class MuzzleFlash : MonoBehaviour
{
public GameObject flash;
void Update()
{
if (Input.GetMouseButton(0))
{
IEnumerator MyMethod()
{
flash.SetActive(true);
yield return new WaitForSeconds(2);
flash.SetActive(false);
}
}
{
}
}
}
Hi,
You can start your Coroutine like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MuzzleFlash : MonoBehaviour
{
public GameObject flash;
void Update()
{
if (Input.GetMouseButton(0))
{
StartCoroutine("MyMethod");
}
}
IEnumerator MyMethod()
{
flash.SetActive(true);
yield return new WaitForSeconds(2);
flash.SetActive(false);
}
}
Please use forum tools to post pieces of code next time.
Thanks man you saved my day sorry
this is my first post next time I’ll be careful what you say