BGE.FishParts.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
        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);
            }
        }
    }