public void SpawnRandomProp(List <RoadObstacle> propList, HighScore highScore, HealthPointsSystem healthPointsSystem, FloatingScoreSpawner floatingScoreSpawner, float chanceToSpawnProp) { if (Random.value <= chanceToSpawnProp) { SpawnRandomProp(propList, highScore, healthPointsSystem, floatingScoreSpawner); } }
public void SpawnRandomProp(List <RoadObstacle> propList, HighScore highScore, HealthPointsSystem healthPointsSystem, FloatingScoreSpawner floatingScoreSpawner) { var propToSpawn = GetRandomProp(propList); var randomPosition = GetRandomPosition(propToSpawn); var prop = Instantiate(propToSpawn, randomPosition, propToSpawn.transform.rotation); prop.highScore = highScore; prop.healthPointsSystem = healthPointsSystem; prop.floatingScoreSpawner = floatingScoreSpawner; Destroy(prop.gameObject, 10f); }