void Start()
    {
        randomFreq = 1.0f / randomFreq;

        if (transform.parent){
            // 指定父物体为leader
            leader = transform.parent.GetComponent<UnityFlockController>();
        }

        if (leader.Flocks != null && leader.FlockCount > 1){
            transform.parent = null;
            // 开始 计算随机移动 的协程
            StartCoroutine(UpdateRandom());
        }
    }
Ejemplo n.º 2
0
    void Start()
    {
        randomFreq = 1.0f / randomFreq;

        if (transform.parent)
        {
            // 指定父物体为leader
            leader = transform.parent.GetComponent <UnityFlockController>();
        }

        if (leader.Flocks != null && leader.FlockCount > 1)
        {
            transform.parent = null;
            // 开始 计算随机移动 的协程
            StartCoroutine(UpdateRandom());
        }
    }
Ejemplo n.º 3
0
    private void Awake()
    {
        if (!instance)
        {
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        flockController = GetComponent <UnityFlockController>();
        targetObject    = Instantiate(targetPrefab, transform.position, transform.rotation) as Target;

        InitSimulation(FlockMode.LAZY);
    }