Example #1
0
    void FixedUpdate()
    {
        //	update gravity vector

        switch (gravityDown)
        {
        case GravityDown.Absolute:
            _thrustVector = Vector3.up;
            break;

        case GravityDown.Relative:
            _thrustVector = _transform.up;
            break;
        }

        //	update relative forces on vehicle

        foreach (Vector3 v3lp in liftPoints)
        {
            Vector3 worldPosition = transform.TransformPoint(v3lp);

            Vector3 forceVector = _thrustVector;
            forceVector *= (_mass + linearLift - 1) * factorLift * hoverAltitude;
            forceVector /= Mathf.Pow(GetAltitudeAtPoint(_transform.TransformPoint(v3lp)), geometricLift);

            _rigidbody.AddForceAtPosition(forceVector, worldPosition, ForceMode.Acceleration);

            if (_debugTick)
            {
                Debug.Log("forceVector: " + forceVector.magnitude +
                          ", altitude: " + UU.Trunc(GetAltitudeAtPoint(_transform.position), 2) +
                          ", divisor: " + Mathf.Pow(GetAltitudeAtPoint(_transform.TransformPoint(v3lp)), geometricLift));
            }
        }

        if (enableGravityKeel)
        {
            RaycastHit data;
            if (Physics.Raycast(_transform.position, -_thrustVector, out data, 18))
            {
                //	rotate toward 'level' as indicated by the surface below
                SelfRightNonKinematic(data.normal);
            }
            else
            {
                //	raycast hit nothing, so we migh be flipped over, or very high
                //	so rotate toward the 'universal' level
                SelfRightNonKinematic(Vector3.up);
            }
        }

        _debugTick = false;
    }
Example #2
0
    void OnGUI()
    {
        if (!showGUI)
        {
            return;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Space(guiPosition.x);
        GUILayout.BeginVertical();
        GUILayout.Space(guiPosition.y);
        GUILayout.Label(stringId + "( " + UU.Trunc(_altitude, 1) + " : " + UU.Trunc(_buoyancyVector.magnitude, 1) + ")");

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }