Example #1
0
        public static SteeringOutput GetSteering(KinematicState ownKS, SAlign info)
        {
            SURROGATE_TARGET.rotation = Quaternion.Euler(SURROGATE_TARGET.eulerAngles.x, MathExtent.VectorToAngle(info.m_target.position - ownKS.m_position), SURROGATE_TARGET.eulerAngles.z);
            info.m_target             = SURROGATE_TARGET;

            return(Align.GetSteering(ownKS, info));
        }
Example #2
0
        public static SteeringOutput GetSteering(KinematicState ownKS, SAlign info)
        {
            float l_requiredAngularSpeed;
            float l_requiredAngularAcceleration;
            float l_angleSize;

            float l_requiredRotation = info.m_target.rotation.eulerAngles.y - ownKS.m_orientation;

            if (l_requiredRotation < 0f)
            {
                l_requiredRotation += 360f;
            }

            if (l_requiredRotation > 180f)
            {
                l_requiredRotation = -(360f - l_requiredRotation);
            }

            l_angleSize = Mathf.Abs(l_requiredRotation);

            if (l_angleSize <= info.m_closeEnoughAngle)
            {
                return(NULL_STEERING);
            }

            if (l_angleSize > info.m_slowDownAngle)
            {
                l_requiredAngularSpeed = ownKS.m_maxAngularSpeed;
            }
            else
            {
                l_requiredAngularSpeed = ownKS.m_maxAngularSpeed * (l_angleSize - info.m_slowDownAngle);
            }

            l_requiredAngularSpeed       *= Mathf.Sign(l_requiredRotation);
            l_requiredAngularAcceleration = (l_requiredAngularSpeed - ownKS.m_angularSpeed) / info.m_timeToDesiredAngularSpeed;

            l_requiredAngularAcceleration = MathExtent.Clip(l_requiredAngularAcceleration, ownKS.m_maxAngularAcceleration, true);

            SteeringOutput result = new SteeringOutput();

            result.m_angularAcceleration = l_requiredAngularAcceleration;
            return(result);
        }
Example #3
0
 public void SetInfo(SAlign info)
 {
     m_info = info;
 }