public static SteeringOutput GetSteering(KinematicState ownKS, SObstacleAvoidance info)
        {
            Ray        l_ray = new Ray(ownKS.m_position, ownKS.m_linearVelocity.normalized);
            RaycastHit l_hitInfo;

            if (Physics.Raycast(l_ray, out l_hitInfo, info.m_avoidDistance))
            {
                SURROGATE_TARGET.position = l_hitInfo.point + l_hitInfo.normal * info.m_avoidDistance;
                return(Seek.GetSteering(ownKS, SURROGATE_TARGET));
            }

            l_ray = new Ray(ownKS.m_position, MathExtent.AngleToVector(MathExtent.VectorToAngle(ownKS.m_linearVelocity.normalized) + info.m_AngleSecondWhisk));

            if (Physics.Raycast(l_ray, out l_hitInfo, info.m_primaryWhiskerLenght * info.m_RatioSecondWhisk))
            {
                SURROGATE_TARGET.position = l_hitInfo.point + l_hitInfo.normal * info.m_avoidDistance;
                return(Seek.GetSteering(ownKS, SURROGATE_TARGET));
            }

            l_ray = new Ray(ownKS.m_position, MathExtent.AngleToVector(MathExtent.VectorToAngle(ownKS.m_linearVelocity.normalized) - info.m_AngleSecondWhisk));

            if (Physics.Raycast(l_ray, out l_hitInfo, info.m_primaryWhiskerLenght * info.m_RatioSecondWhisk))
            {
                SURROGATE_TARGET.position = l_hitInfo.point + l_hitInfo.normal * info.m_avoidDistance;
                return(Seek.GetSteering(ownKS, SURROGATE_TARGET));
            }

            return(NULL_STEERING);
        }
Пример #2
0
        public static SteeringOutput GetSteering(KinematicState ownKS)
        {
            Vector3 l_direction = MathExtent.AngleToVector(ownKS.m_orientation);

            SURROGATE_TARGET.position = ownKS.m_position + l_direction;

            return(Seek.GetSteering(ownKS, SURROGATE_TARGET));
        }
Пример #3
0
        public static SteeringOutput GetSteering(KinematicState ownKS, ref SWander info)
        {
            info.m_targetOrientation           += info.m_wanderRate * MathExtent.Binomial();
            SURROGATE_TARGET.transform.position = MathExtent.AngleToVector(info.m_targetOrientation) * info.m_wanderRadius;

            SURROGATE_TARGET.transform.position += ownKS.m_position + MathExtent.AngleToVector(ownKS.m_orientation) * info.m_wanderOffset;

            return(Seek.GetSteering(ownKS, SURROGATE_TARGET));
        }
Пример #4
0
        public static SteeringOutput GetSteering(KinematicState me, SKeepPosition info)
        {
            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;

            return(Seek.GetSteering(me, SURROGATE_TARGET));
        }