示例#1
0
        public void Update()
        {            
            float fleeForce = GetComponent<Boid>().fleeForce.magnitude;            
            if (fleeForce  > 0)
            {
                BoidManager.PrintFloat("Flee force: ", fleeForce);
                fleeColourWait = 0.1f; // 100000.0f / fleeForce;
                BoidManager.PrintFloat("Flee wait: ", fleeColourWait);
                if (!fleeColourStarted)
                {
                    StartCoroutine("FleeColourCycle");
                }
            }
            // Animate the head            
            float headRot = Mathf.Sin(theta) * headField;
            head.transform.RotateAround(transform.TransformPoint(headRotPoint), transform.up, headRot - oldHeadRot);            
            
            oldHeadRot = headRot;

            // Animate the tail
            float tailRot = Mathf.Sin(theta) * tailField;
            tail.transform.RotateAround(transform.TransformPoint(tailRotPoint), transform.up, tailRot - oldTailRot);
            oldTailRot = tailRot;

            float speed = GetComponent<Boid>().acceleration.magnitude;
            theta += speed * angularVelocity * Time.deltaTime * speedMultiplier;            
            if (theta >= Mathf.PI * 2.0f)
            {
                theta -= (Mathf.PI * 2.0f);
            }
        }
示例#2
0
        void Start()
        {
            instance       = this;
            Cursor.visible = false;

            style.fontSize         = 18;
            style.normal.textColor = Color.white;

            space     = new Space(spaceBounds.x, spaceBounds.y, spaceBounds.z, numCells);
            obstacles = GameObject.FindObjectsOfType(typeof(Obstacle)) as Obstacle[];
        }
示例#3
0
 BoidManager()
 {
     spaceBounds = new Vector3(1000, 1000, 1000);
     numCells    = 50;
     instance    = this;
 }
示例#4
0
 BoidManager()
 {
     spaceBounds = new Vector3(1000, 1000, 1000);
     numCells = 50;
     instance = this;
 }
示例#5
0
        void Start()
        {
            instance = this;
            Cursor.visible = false;

            style.fontSize = 18;
            style.normal.textColor = Color.white;

            space = new Space(spaceBounds.x, spaceBounds.y, spaceBounds.z, numCells);
            obstacles = GameObject.FindObjectsOfType(typeof(Obstacle)) as Obstacle[];
        }