コード例 #1
0
        /// <summary>
        /// Progress orbit path motion.
        /// Actual kepler orbiting is processed here.
        /// </summary>
        /// <remarks>
        /// Orbit motion progress calculations must be placed after Update, so orbit parameters changes can be applyed,
        /// but before LateUpdate, so orbit can be displayed in same frame.
        /// Coroutine loop is best candidate for achieving this.
        /// </remarks>
        private IEnumerator OrbitUpdateLoop()
        {
            while (true)
            {
                if (IsReferencesAsigned)
                {
                    if (!OrbitData.IsValidOrbit)
                    {
                        //try to fix orbit if we can.
                        OrbitData.CalculateNewOrbitData();
                    }

                    if (OrbitData.IsValidOrbit)
                    {
                        OrbitData.UpdateOrbitDataByTime(Time.deltaTime * TimeScale);

                        transform.position = AttractorSettings.AttractorObject.position + (Vector3)OrbitData.Position;
                        if (VelocityHandle != null)
                        {
                            VelocityHandle.position = transform.position + (Vector3)OrbitData.Velocity;
                        }
                    }
                }
                yield return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// Progress orbit path motion.
        /// Actual kepler orbiting is processed here.
        /// </summary>
        /// <remarks>
        /// Orbit motion progress calculations must be placed after Update, so orbit parameters changes can be applyed,
        /// but before LateUpdate, so orbit can be displayed in same frame.
        /// Coroutine loop is best candidate for achieving this.
        /// </remarks>
        private IEnumerator OrbitUpdateLoop()
        {
            while (true)
            {
                if (IsReferencesAsigned)
                {
                    if (!OrbitData.IsValidOrbit)
                    {
                        //try to fix orbit if we can.
                        OrbitData.CalculateNewOrbitData();
                    }

                    if (OrbitData.IsValidOrbit)
                    {
                        OrbitData.UpdateOrbitDataByTime(Time.deltaTime * TimeScale);
                        ForceUpdateViewFromInternalState();
                    }
                }
                yield return(null);
            }
        }