none
Assets/Scripts/SpawnsManager.cs(37,19): error CS1061: Type `UnityEngine.GameObject' does not contain a definition for `currentTime' and no extension method `currentTime' of type `UnityEngine.GameObject' could be found.

    Pertanyaan

  • using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    
    public class SpawnsManager : MonoBehaviour
    {
        public GameObject granny;
    
        public int spawns;
        public Transform[] spawn;
        public Transform chosenSpawnObj;
    
        public float waitTimer;
        public static float _waitTimer;
        public float FoodPercent;
    
        public static bool spawnFood;    //set value in here 
        public static float spawnTimer;  //set value in here 
        public static int chosenSpawn;
    
        public GameObject[] food;
        public GameObject Pill;
    
        public void Start()
    
        {
            spawn = new Transform[16];
            spawns = this.transform.childCount;
            for (int i = 0; i < spawns; i++)
                spawn[i] = this.transform.GetChild(i);
    
            _waitTimer = waitTimer;
        }
    
        public void Update()
        {
            if(granny.currentTime > 0)
            {
                if(_waitTimer > 0)
                    _waitTimer -= 1 * Time.deltaTime;
                else
                    Spawn();
            }
        }
    
            public void Spawn()
        { 
            chosenSpawn = Random.Range(0, spawns);
            chosenSpawnObj = spawn[chosenSpawn];
    
            //randomly calculate if it ll be a Food or not 
            if (Random.value > FoodPercent)
                spawnFood = true;
    
            //spawn Pill
            Vector3 pos = new Vector3(chosenSpawnObj.position.x, chosenSpawnObj.position.y - 1.5f, chosenSpawnObj.position.z);
            if (spawnFood)
                Instantiate(food[Random.Range(0, food.Length)]);
            else
                Instantiate(Pill, pos, Quaternion.identity);
    
            //set finalized results and make it loop 
            spawnFood = false;
            _waitTimer = waitTimer;
         }
    
    }

    • Dipindahkan oleh CoolDadTxMVP Kamis, 17 Mei 2018 15.25 Third party product
    Kamis, 17 Mei 2018 12.09

Semua Balasan