public void Attack() { GameObject bullet = Instantiate(playerBullet.gameObject, bulletSpawner.transform.position, bulletSpawner.transform.rotation); bullets.Add(bullet.GetComponent <PlayerBullet>()); foreach (PlayerBullet r in bullets) { PlayerBullet pBullet = bullet.GetComponent <PlayerBullet>(); if (pBullet) { pBullet.playerController = this; } pBullet.Projectile(); } if (bullets.Count > 1) { bullets.RemoveAt(0); } attackCD = initAttackCD; attack = false; }