Пример #1
0
        public static SteeringOutput GetSteering(KinematicState ownKS, SArrive info)
        {
            Vector3 l_distanceToTarget = info.m_target.position - ownKS.m_position;

            if (l_distanceToTarget.magnitude < info.m_closeEnoughRadius)
            {
                return(NULL_STEERING);
            }

            if (l_distanceToTarget.magnitude > info.m_slowDownRadius)
            {
                return(Seek.GetSteering(ownKS, info.m_target));
            }

            float   l_desiredSpeed    = ownKS.m_maxLinearSpeed * (l_distanceToTarget.magnitude / info.m_slowDownRadius);
            Vector3 l_desiredVelocity = l_distanceToTarget.normalized * l_desiredSpeed;

            Vector3 l_requiredAcceleration = (l_desiredVelocity - ownKS.m_linearVelocity) / info.m_timeToDesiredSpeed;

            l_requiredAcceleration = MathExtent.Clip(l_requiredAcceleration, ownKS.m_maxLinearAcceleration);

            SteeringOutput result = new SteeringOutput();

            result.m_linearAcceleration = l_requiredAcceleration;

            return(result);
        }
Пример #2
0
        public static SteeringOutput GetSteering(KinematicState me, SKeepPosition info, SArrive arriveInfo)
        {
            float targetOrientation = info.m_target.transform.eulerAngles.y;

            targetOrientation += info.m_requiredAngle;

            Vector3 finalTargetPosition = MathExtent.AngleToVector(targetOrientation).normalized;

            finalTargetPosition *= info.m_requiredDistance;

            SURROGATE_TARGET.position = info.m_target.position + finalTargetPosition;
            arriveInfo.m_target       = SURROGATE_TARGET;

            return(Arrive.GetSteering(me, arriveInfo));
        }
Пример #3
0
 public void SetInfo(SKeepPosition info, SArrive arriveInfo)
 {
     m_keepPositioninfo = info;
     m_arriveInfo       = arriveInfo;
 }
Пример #4
0
 public void SetInfo(SArrive info)
 {
     m_info = info;
 }