private void OnDestroy()
 {
     if (parent)
     {
         parent.GetComponent <ObjectSpawner>().StartSpawnDelay();
     }
 }
Exemple #2
0
    void CreateSpawner(int index)
    {
        Transform rotater = new GameObject("Rotater").transform;

        rotater.SetParent(transform, false);
        rotater.localRotation =
            Quaternion.Euler(0f, index * 360f / numberOfSpawners, 0f);

        ObjectSpawner spawner = Instantiate <ObjectSpawner>(spawnerPrefab);

        spawner.GetComponent <ObjectSpawner>().objectMaterial = objectMaterials[Random.Range(0, objectMaterials.Length)];
        spawner.transform.SetParent(rotater, false);
        spawner.transform.localPosition = new Vector3(0f, 0f, radius);
        spawner.transform.localRotation = Quaternion.Euler(-tiltAngle, 0f, 0f);
    }