예제 #1
0
 void valueInitialize()
 {
     _Acceleration          = 0;
     oldXRotation           = transform.rotation.eulerAngles.x;
     oldYRotation           = transform.rotation.eulerAngles.y;
     oldZRotation           = transform.rotation.eulerAngles.z;
     _gravity               = _constval.GetGravity();
     propellerDiameter      = _constval.GetPropellerDiameter();
     propellerVelocity      = _constval.GetAngularVelocity();
     maxRPM                 = _constval.GetMaxRPM();
     airDensity             = _constval.GetAirDensity();
     thrustCoefficient      = _constval.GetC_T();
     powerCoefficient       = _constval.GetC_Pow();
     linearDragCoefficient  = _constval.GetClin();
     AngularDragCoefficient = _constval.GetC_AngularDrag();
 }
예제 #2
0
    void PropellerForce()
    {
        if ((Mathf.Abs(Input.GetAxis("Vertical")) > 0.2f) || (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.2f))
        {
            if (Input.GetAxis("FlyUp") == 0 && (Mathf.Abs(Input.GetAxis("Vertical")) > 0.2f))
            {
                upForce = _constval.GetC_T() * _constval.GetAirDensity() * Mathf.Pow(_constval.GetAngularVelocity(), 2)
                          * Mathf.Pow(_constval.GetPropellerDiameter(), 4) * Mathf.Abs(Input.GetAxis("Vertical"));
                curRPM = Mathf.Abs(_constval.GetMaxRPM() * Input.GetAxis("Vertical"));

                tiltAmount = 40;
            }
            if (Input.GetAxis("FlyUp") == 0 && (Mathf.Abs(Input.GetAxis("Horizontal")) > 0.2f))
            {
                upForce = _constval.GetC_T() * _constval.GetAirDensity() * Mathf.Pow(_constval.GetAngularVelocity(), 2)
                          * Mathf.Pow(_constval.GetPropellerDiameter(), 4) * Mathf.Abs(Input.GetAxis("Horizontal"));
                curRPM     = Mathf.Abs(_constval.GetMaxRPM() * Input.GetAxis("Horizontal"));
                tiltAmount = 40;
            }
        }

        if (Mathf.Abs(Input.GetAxis("FlyUp")) >= 0.3f)
        {
            upForce = _constval.GetC_T() * _constval.GetAirDensity() * Mathf.Pow(_constval.GetAngularVelocity(), 2)
                      * Mathf.Pow(_constval.GetPropellerDiameter(), 4) * Input.GetAxis("FlyUp");

            if ((Mathf.Abs(Input.GetAxis("Vertical")) != 0) || (Mathf.Abs(Input.GetAxis("Horizontal")) != 0))
            {
                tiltAmount = 20;
            }
            else
            {
                tiltAmount = 0;
            }
            curRPM = Mathf.Abs(_constval.GetMaxRPM() * Input.GetAxis("FlyUp"));
        }

        if (Input.GetAxis("FlyUp") == 0 && Input.GetAxis("Vertical") == 0 && Input.GetAxis("Horizontal") == 0)
        {
            upForce = Mathf.SmoothDamp(upForce, 0, ref refForce, 1f);
            curRPM  = Mathf.SmoothDamp(curRPM, 0, ref refRPM, 1 / Mathf.Pow(2, 0.5f));
        }
    }