private void Shoot() { GameObject newBullet = Instantiate(ResourcesLoader.GetBullet(), transform.position, transform.rotation); newBullet.tag = "EnemyBullet"; var spaceshipController = SceneHelper.GetSpaceship().GetComponent <SpaceshipController>(); var bulletForce = spaceshipController.bulletForce; var bulletLifeTime = spaceshipController.bulletLifeTime; newBullet.GetComponent <Rigidbody2D>().AddRelativeForce( new Vector2(Random.Range(-1.0f, 1.0f), Random.Range(-1.0f, 1.0f)).normalized *bulletForce); Destroy(newBullet, bulletLifeTime); Invoke(nameof(Shoot), 1 / rateOfFire); }