DirectionalSpeed() публичный статический Метод

public static DirectionalSpeed ( Vector3 Direction, UnityEngine.Vector3d Velocity ) : float
Direction Vector3
Velocity UnityEngine.Vector3d
Результат float
Пример #1
0
        public override void OnUpdate()
        {
            if (!flightStarted)
            {
                return;
            }

            switch (mode)
            {
            case TrackingModes.BROKEN:
                return;

            case TrackingModes.TRACKING:
                if (target.isTarget && powered)
                {
                    pivot1.RotToTarget(target.position);
                    pivot2.RotToTarget(target.position);
                }
                break;

            case TrackingModes.EXTENDING:
                if (!anim.IsPlaying(Animation))
                {
                    mode = TrackingModes.TRACKING;
                }
                break;

            case TrackingModes.RETRACTING:
                if (!anim.IsPlaying(Animation))
                {
                    mode = TrackingModes.RETRACTED;
                }
                break;

            case TrackingModes.RESETTING:
                if (pivot1.RotToOrigin() & pivot2.RotToOrigin())
                {
                    anim[Animation].speed = -Mathf.Abs(anim[Animation].speed);

                    anim.Play(Animation);

                    if (anim[Animation].normalizedTime == 0)
                    {
                        anim[Animation].normalizedTime = 1;
                    }
                    mode = TrackingModes.RETRACTING;
                }
                break;
            }

            if (EnergyDrain1 > 0)
            {
                RequestPower();
            }

            if (vessel != null && RTUtils.PhysicsActive)
            {
                if (willWakeInPanic && animState == 0 && !InControl && !anim.IsPlaying(Animation))
                {
                    SetMode1();
                    UpdateGUI();
                }


                if (MaxQ > 0 && mode != TrackingModes.RETRACTED && vessel.atmDensity > 0 && (Math.Pow(RTUtils.DirectionalSpeed(Pivot2Dir.up, vessel.srf_velocity), 2) * vessel.atmDensity * 0.5) > MaxQ)
                {
                    broken = true;
                    mode   = TrackingModes.BROKEN;
                    List <Transform> toRemove = new List <Transform>();
                    RTUtils.findTransformsWithCollider(part.FindModelTransform(Pivot1Name), ref toRemove);

                    foreach (Transform t in toRemove)
                    {
                        Rigidbody rb = t.gameObject.AddComponent <Rigidbody>();

                        rb.angularDrag     = 0;
                        rb.angularVelocity = part.rigidbody.angularVelocity;
                        rb.drag            = 0;
                        rb.mass            = t.collider.bounds.size.x * t.collider.bounds.size.y * t.collider.bounds.size.z * ShrapnelDensity;
                        rb.velocity        = part.rigidbody.velocity;
                        rb.isKinematic     = false;
                        t.parent           = null;
                        rb.AddForce(UnityEngine.Random.Range(-5, 5), UnityEngine.Random.Range(-5, 5), UnityEngine.Random.Range(-5, 5));
                        rb.AddTorque(UnityEngine.Random.Range(-20, 20), UnityEngine.Random.Range(-20, 20), UnityEngine.Random.Range(-20, 20));

                        DragModel dm = t.gameObject.AddComponent <DragModel>();
                        dm.enabled = true;
                        dm.tf      = t;
                        dm.rb      = rb;
                        dm.dc      = ShrapnelDragCoeff;
                        dm.mb      = vessel.mainBody;
                    }

                    if (this.MaximumDrag > 0)
                    {
                        part.minimum_drag = this.MinimumDrag;
                        part.maximum_drag = this.MaximumDrag;
                    }

                    EnergyDrain = antennaRange = dishRange = 0;
                    part.SendMessage("UpdateGUI");
                    UpdatePA();
                    RTGlobals.network = new RelayNetwork();
                }
            }
        }