Exemple #1
0
        public void Play(Vector3 _startPos, Vector3 _endPos, float _angle, float _horiSpeed)
        {
            base.Play(_startPos, Vector3.zero);
            Vector3 horiDirection = UVector.GetXZLookDirection(_startPos, _endPos);
            Vector3 horiRight     = horiDirection.RotateDirectionClockwise(Vector3.up, 90);

            m_Direction       = horiDirection.RotateDirectionClockwise(horiRight, -_angle);
            m_HorizontalSpeed = _horiSpeed / Mathf.Cos(_angle * Mathf.Deg2Rad);
            m_SpeedMultiplier = 1f;
            float horiDistance  = Vector3.Distance(_startPos, _endPos);
            float duration      = horiDistance / _horiSpeed;
            float vertiDistance = Mathf.Tan(_angle * Mathf.Deg2Rad) * horiDistance;

            m_VerticalAcceleration = PhysicsExpressions.GetAcceleration(0, vertiDistance, duration);
        }
Exemple #2
0
        public override Vector3 GetSimulatedPosition(float elapsedTime)
        {
            Vector3 horizontalShift = Vector3.zero;

            if (!(m_horizontalSpeed > 0 && m_horizontalAcceleration < 0))
            {
                float aboveZeroTime = m_horizontalSpeed / Mathf.Abs(m_horizontalAcceleration);

                horizontalShift += m_HorizontalDirection * PhysicsExpressions.AccelerationSpeedShift(m_horizontalSpeed, m_horizontalAcceleration, elapsedTime > aboveZeroTime ? aboveZeroTime : elapsedTime);
            }

            Vector3 targetPos = m_Origin + horizontalShift;

            return(targetPos);
        }
Exemple #3
0
 public override Vector3 GetSimulatedPosition(float elapsedTime) => m_Origin + m_Direction * PhysicsExpressions.SpeedShift(m_Speed, elapsedTime);