예제 #1
0
    public void spawnManyKids(float number)
    {
        for (int i = 0; i < number; i++)
        {
            GameObject obj = spawnKid();

            script_childBehaviour behaviour = obj.GetComponent <script_childBehaviour>();
            behaviour.init();
            if (i == 0)
            {
                behaviour.setAsthmatic();
                obj.GetComponent <script_audioScript>().startWorking();
            }
            else
            {
                script_audioScript a = obj.GetComponent <script_audioScript>();
                AudioSource        s = obj.GetComponent <AudioSource>();
                if (a)
                {
                    Destroy(a);
                }
                if (s)
                {
                    Destroy(s);
                }
            }

            if (Random.Range(0f, 1f) < pctWalking)
            {
                behaviour.changeState(childState.walk);
            }
        }
        Destroy(generatedObject);
    }
예제 #2
0
 //FUNCTIONS
 void Start()
 {
     audioScr  = GetComponent <script_audioScript>();
     layerMask = LayerMask.GetMask("child");
     cam       = GetComponentInChildren <Camera>();
     rb        = GetComponent <Rigidbody>();
     if (colTay)
     {
         colTay.enabled = false;
     }
 }