예제 #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));
        }
예제 #2
0
        public static SteeringOutput GetSteering(KinematicState ownKS, float wanderRate = 30f, float targetAngularRadius       = 2f,
                                                 float slowDownAngularRadius            = 10f, float timeToDesiredAngularSpeed = 0.1f)
        {
            // align with a surrogate target that has your new orientation and go there

            // slightly change the orientation
            float desiredOrientation = ownKS.orientation + wanderRate * Utils.binomial();

            // give that orientation to the surrogate target
            SURROGATE_TARGET.transform.rotation = Quaternion.Euler(0, 0, desiredOrientation);

            // align with the surrogate target
            SteeringOutput al = Align.GetSteering(ownKS, SURROGATE_TARGET, targetAngularRadius, slowDownAngularRadius, timeToDesiredAngularSpeed);

            // go where you look (looked, actually)
            SteeringOutput gwyl = GoWhereYouLook.GetSteering(ownKS);             // should never return null

            // combine, if possible
            if (al != null)
            {
                gwyl.angularActive       = true;
                gwyl.angularAcceleration = al.angularAcceleration;
            }

            return(gwyl);
        }
예제 #3
0
        public override SteeringOutput GetSteering()
        {
            // no KS? get it
            if (this.ownKS == null)
            {
                this.ownKS = GetComponent <KinematicState>();
            }

            return(Align.GetSteering(this.ownKS, this.target, this.closeEnoughAngle, this.slowDownAngle, this.timeToDesiredAngularSpeed));
        }
예제 #4
0
        public override SteeringOutput GetSteering()
        {
            // no KS? get it
            if (this.ownKS == null)
            {
                this.ownKS = GetComponent <KinematicState>();
            }

            // being a rotational behaviour, align applies no rotational policy
            return(Align.GetSteering(this.ownKS, this.target, this.closeEnoughAngle, this.slowDownAngle, this.timeToDesiredAngularSpeed));
        }
예제 #5
0
        public static SteeringOutput GetSteering(KinematicState ownKS, GameObject target,
                                                 float targetAngularRadius       = 2f,
                                                 float slowDownAngularRadius     = 10f,
                                                 float timeToDesiredAngularSpeed = 0.1f)
        {
            Vector3 directionToTarget = target.transform.position - ownKS.position;

            SURROGATE_TARGET.transform.rotation = Quaternion.Euler(0, 0, Utils.VectorToOrientation(directionToTarget));

            // Align with surrogate target
            return(Align.GetSteering(ownKS, SURROGATE_TARGET, targetAngularRadius,
                                     slowDownAngularRadius, timeToDesiredAngularSpeed));
        }
예제 #6
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;
     }
 }
예제 #7
0
        public static SteeringOutput GetSteering(KinematicState ownKS, GameObject target,
                                                 float targetAngularRadius,
                                                 float slowDownAngularRadius,
                                                 float timeToDesiredAngularSpeed)
        {
            Vector3 directionToTarget = target.transform.position - ownKS.position;

            if (surrogateTarget == null)
            {
                surrogateTarget = new GameObject("Surrogate Target for Face");
            }

            surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, Utils.VectorToOrientation(directionToTarget));

            // Align with surrogate target
            return(Align.GetSteering(ownKS, surrogateTarget, targetAngularRadius, slowDownAngularRadius, timeToDesiredAngularSpeed));
        }
        public virtual void applyLWYG(SteeringOutput steering)
        {
            if (ownKS.linearVelocity.magnitude > 0.001f)
            {
                // if linear velocity is very small, object is not moving (isn't going anywhere
                // hence it makes no sense to apply "look where you go"

                // Align with velocity.
                // create a surrogate target the orientation of which is that of my linear velocity
                SURROGATE_TARGET.transform.rotation = Quaternion.Euler(0, 0, Utils.VectorToOrientation(ownKS.linearVelocity));
                SteeringOutput st = Align.GetSteering(ownKS, SURROGATE_TARGET);
                steering.angularAcceleration = st.angularAcceleration;
                steering.angularActive       = st.angularActive;
            }
            else
            {
                steering.angularActive = false;
            }
        }
예제 #9
0
        public override SteeringOutput GetSteering()
        {
            SteeringOutput result = WanderPlusAvoid.GetSteering(ownKS, wanderRate, wanderRate, wanderOffset, ref targetOrientation, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio, ref avoidActive, avoidLayers, scanner);

            if (!surrogateTarget)
            {
                return(null);
            }
            if (ownKS.linearVelocity.magnitude > 0.001f)
            {
                surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity));
                SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget);
                result.angularAcceleration = st.angularAcceleration;
                result.angularActive       = st.angularActive;
            }
            else
            {
                result.angularActive = false;
            }

            return(result);
        }
예제 #10
0
        public override SteeringOutput GetSteering()
        {
            SteeringOutput result = LinearRepulsion.GetSteering(this.ownKS, this.idTag, this.repulsionThreshold);

            if (!surrogateTarget)
            {
                return(null);
            }

            if (ownKS.linearVelocity.magnitude > 0.001f)
            {
                surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity));
                SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget);
                result.angularAcceleration = st.angularAcceleration;
                result.angularActive       = st.angularActive;
            }
            else
            {
                result.angularActive = false;
            }

            return(result);
        }
예제 #11
0
        public override SteeringOutput GetSteering()
        {
            SteeringOutput result = Wander.GetSteering(ownKS, ref targetOrientation, wanderRate, wanderRadius, wanderOffset);

            if (!surrogateTarget)
            {
                return(null);
            }

            if (ownKS.linearVelocity.magnitude > 0.001f)
            {
                surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity));
                SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget);
                result.angularAcceleration = st.angularAcceleration;
                result.angularActive       = st.angularActive;
            }
            else
            {
                result.angularActive = false;
            }

            return(result);
        }
예제 #12
0
파일: Arrive.cs 프로젝트: NoctisRB/Eddy
        public override SteeringOutput GetSteering()
        {
            SteeringOutput result = Arrive.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed);

            if (!surrogateTarget)
            {
                return(null);
            }

            if (ownKS.linearVelocity.magnitude > 0.001f)
            {
                surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity));
                SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget);
                result.angularAcceleration = st.angularAcceleration;
                result.angularActive       = st.angularActive;
            }
            else
            {
                result.angularActive = false;
            }

            return(result);
        }
예제 #13
0
        public override SteeringOutput GetSteering()
        {
            SteeringOutput result = ArrivePlusAvoid.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio, avoidLayers, scanner, repulsionTag, repulsionThreshold, arriveWeight);

            if (!surrogateTarget)
            {
                return(null);
            }

            if (ownKS.linearVelocity.magnitude > 0.001f)
            {
                surrogateTarget.transform.rotation = Quaternion.Euler(0, 0, VectorToOrientation(ownKS.linearVelocity));
                SteeringOutput st = Align.GetSteering(ownKS, surrogateTarget);
                result.angularAcceleration = st.angularAcceleration;
                result.angularActive       = st.angularActive;
            }
            else
            {
                result.angularActive = false;
            }

            return(result);
        }
예제 #14
0
 protected override SteeringOutput GetSteering()
 {
     return(Align.GetSteering(m_ownKS, m_info));
 }
예제 #15
0
파일: Align.cs 프로젝트: NoctisRB/Eddy
 public override SteeringOutput GetSteering()
 {
     return(Align.GetSteering(this.ownKS, this.target, this.closeEnoughAngle, this.slowDownAngle, this.timeToDesiredAngularSpeed));
 }