void rotateBlades(Vector3 rot)
 {
     for (int i = 0; i < rotorblades.Count; ++i)
     {
         GameObject go  = (GameObject)rotorblades [i];
         Rotorblade rbb = go.GetComponent <Rotorblade> ();
         rbb.rotateAngle(rot);
     }
 }
 //Rotate all blades on the z axis with the specified amount.
 public void rotateBlades(float amount)
 {
     for (int i = 0; i < rotorblades.Count; ++i)
     {
         GameObject b  = (GameObject)rotorblades [i];
         Rotorblade rb = b.GetComponent <Rotorblade> ();
         rb.rotateAngle(new Vector3(amount, 0, 0));               //z x y
     }
 }
    // Update is called once per frame
    void Update()
    {
        float dT = Time.deltaTime;

        //Engine
        EngineControl ec = target.GetComponent <EngineControl> ();

        ec.doUpdate(dT);
        w = ec.currentAngularVelocity(w);

        //Tilting
        TiltingControl tc            = target.GetComponent <TiltingControl> ();
        Vector3        tiltRotations = tc.doUpdate(dT);

        //RotorBlades.rotateBlades (tiltRotations);
        target.transform.Rotate(tiltRotations);

        //Z-rotation
        if (TiltingControl.inputSelector == 0)
        {
            if (Input.GetKey(KeyCode.A))
            {
                target.transform.Rotate(0, -40 * dT, 0);
            }
            else if (Input.GetKey(KeyCode.D))
            {
                target.transform.Rotate(0, 40 * dT, 0);
            }
        }
        else
        {
            target.transform.Rotate(0, 40 * dT * Input.GetAxisRaw("Z-Axis"), 0);
        }

        //Rotation animation
        spin    spinner   = target.GetComponent <spin> ();
        Vector3 rotorSpin = spinner.spinRotor(w);
        var     rotor     = target.transform.Find("Rotor_Control");

        rotor.transform.Rotate(rotorSpin);

        //Calculating the forces generated by virtual rotorblades
        float forceMag = 0.0f;

        for (int i = 0; i < rotorblades.Count; ++i)
        {
            GameObject g  = (GameObject)rotorblades [i];
            Rotorblade rb = g.GetComponent <Rotorblade> ();
            forceMag += rb.getForce();
        }
        //Applying the forces
        target.GetComponent <Rigidbody> ().AddForce(target.transform.up * forceMag);         //Should be correct
    }
 void Start()
 {
     target = tar;
     for (int i = 0; i < heliPos.Length; ++i)
     {
         GameObject r  = new GameObject();
         Rotorblade rb = r.AddComponent <Rotorblade> ();
         rb.initBlade(heliPos[i], i);
         rotorblades.Add(r);
     }
     target.AddComponent <EngineControl> ();
     target.AddComponent <TiltingControl> ();
     target.AddComponent <spin> ();
 }