I’m trying to spawn a circle to show the splash radius of a projectile but the coroutine to destroy the object is not running.
The prefab is spawning in like I expect it to but it is not destroyed.
Currently the script reads,
public GameObject splashObjPrefab;
if (splash)
{
GameObject _splashObj = Instantiate(splashObjPrefab, this.transform.position, Quaternion.identity);
_splashObj.transform.localScale = new Vector3(splashRange * 2, splashRange * 2, 1);
StartCoroutine(DestroySplash(_splashObj));
Debug.Log("Run Coroutine");
}
Destroy(gameObject);
}
private IEnumerator DestroySplash(GameObject _splashObj)
{
yield return new WaitForSeconds(0.2f);
Debug.Log("DestroySplash");
Destroy(_splashObj);
}
The console is showing the ‘Run couroutine’ text but not the ‘DestroySplash’ Text