public void PlaceExplosion(Vector3 position) { if (IsCloseToPlayer(position) && StartAnimation(position, explosions)) { soundEffects.PlayOnExplode(); } }
/** * Finds an unused explosion and activates it */ public void PlaceExplosion(Vector3 position) { for (int i = 0; i < explosions.Count; ++i) { if (!explosions[i].activeSelf) { position.z = explosionAnimation.transform.position.z; explosions[i].SetActive(true); explosions[i].transform.position = position; explosions[i].GetComponent <Animator>().enabled = true; soundEffects.PlayOnExplode(); return; } } Debug.LogError("Could not find inactive explosion sprite to use"); }