void Detonate() { GetComponent <Animator>().Play("Spring"); canDetect = false; if (spikes > 0) { for (int i = 0; i < spikes; i++) { var instance = Instantiate(spikePrefab); ProjectileControl p = instance.GetComponent <ProjectileControl>(); p.setUnitType(UnitType.Ally); float xDir = Random.Range(-20, 20); float yDir = 20 - Mathf.Abs(xDir); p.SetUp(5, new Vector2(xDir, yDir), true, 0, 0); p.DontCollideWithWalls(1); p.transform.position = transform.position; } } }