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);
        }
Exemplo n.º 2
0
        public virtual void ApplyFTI(SteeringOutput steering, GameObject target)
        {
            transform.rotation    = Quaternion.Euler(0, MathExtent.VectorToAngle(target.transform.position - m_ownKS.m_position) - 90f, 0);
            m_ownKS.m_orientation = transform.rotation.eulerAngles.y;

            steering.m_angularActive = false;
        }
Exemplo n.º 3
0
 protected virtual void ApplyLWYGI(SteeringOutput steering)
 {
     if (m_ownKS.m_linearVelocity.magnitude > 0.001f)
     {
         transform.rotation    = Quaternion.Euler(0f, MathExtent.VectorToAngle(m_ownKS.m_linearVelocity), 0f);
         m_ownKS.m_orientation = transform.rotation.eulerAngles.y;
     }
     steering.m_angularActive = false;
 }
Exemplo n.º 4
0
 protected virtual void ApplyLWYG(SteeringOutput steering)
 {
     if (m_ownKS.m_linearVelocity.magnitude > 0.001f)
     {
         SURROGATE_TARGET.transform.rotation = Quaternion.Euler(0, MathExtent.VectorToAngle(m_ownKS.m_linearVelocity), 0);
         m_alignInfo.m_target = SURROGATE_TARGET;
         SteeringOutput st = Align.GetSteering(m_ownKS, m_alignInfo);
         steering.m_angularAcceleration = st.m_angularAcceleration;
         steering.m_angularActive       = st.m_angularActive;
     }
     else
     {
         steering.m_angularActive = false;
     }
 }
Exemplo n.º 5
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));
        }