protected override SteeringOutput GetSteering()
        {
            SteeringOutput result = Arrive.GetSteering(m_ownKS, m_info);

            base.ApplyFacingPolicy(m_info.m_facingPolicy, result);

            return(result);
        }
        public static SteeringOutput GetSteering(KinematicState me, GameObject target, float distance, float angle)
        {
            float   desiredAngle = target.transform.eulerAngles.z + angle;
            Vector3 desiredDirectionFromTarget = Utils.OrientationToVector(desiredAngle).normalized;

            desiredDirectionFromTarget         *= distance;
            SURROGATE_TARGET.transform.position = desiredDirectionFromTarget + target.transform.position;

            return(Arrive.GetSteering(me, SURROGATE_TARGET, 0, 5, 0.1f));
        }
Beispiel #3
0
        public override SteeringOutput GetSteering()
        {
            // no KS? get it
            if (this.ownKS == null)
            {
                this.ownKS = GetComponent <KinematicState>();
            }

            return(Arrive.GetSteering(this.ownKS, this.target, this.closeEnoughRadius, this.slowDownRadius, this.timeToDesiredSpeed));
        }
        public static SteeringOutput GetSteering(KinematicState ownKS, GameObject target, float requiredDistance)
        {
            Vector3 directiofromTaget;

            directiofromTaget = ownKS.position - target.transform.position;
            directiofromTaget.Normalize();
            SURROGATE_TARGET.transform.position = target.transform.position + directiofromTaget * requiredDistance;

            //return Seek.GetSteering(ownKS, SURROGATE_TARGET);
            return(Arrive.GetSteering(ownKS, SURROGATE_TARGET, 0, 5, 0.1f));
        }
        public override SteeringOutput GetSteering()
        {
            // no KS? get it
            if (this.ownKS == null)
            {
                this.ownKS = GetComponent <KinematicState>();
            }

            SteeringOutput result = Arrive.GetSteering(this.ownKS, this.target, this.closeEnoughRadius,
                                                       this.slowDownRadius, this.timeToDesiredSpeed);

            base.applyRotationalPolicy(rotationalPolicy, result, target);
            return(result);
        }
Beispiel #6
0
        public static SteeringOutput GetSteering(KinematicState ownKS, GameObject target, float closeEnoughRadius, float slowDownRadius, float timeToDesiredSpeed, float lookAheadLength, float avoidDistance, float secondaryWhiskerAngle, float secondaryWhiskerRatio, LayerMask avoidLayers, SphereCollider scanner, string repulsionTag, float repulsionThreshold, float arriveWeight)
        {
            SteeringOutput steeringOutput = ObstacleAvoidance.GetSteering(ownKS, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio, avoidLayers, scanner);

            if (steeringOutput == nullSteering)
            {
                SteeringOutput arrive          = Arrive.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed);
                SteeringOutput linearRepulsion = LinearRepulsion.GetSteering(ownKS, repulsionTag, repulsionThreshold);
                arrive.linearAcceleration = arrive.linearAcceleration * arriveWeight + linearRepulsion.linearAcceleration * (1 - arriveWeight);
                return(arrive);
            }

            return(steeringOutput);
        }
        public static SteeringOutput GetSteering(KinematicState ownKS,
                                                 GameObject target, float closeEnoughRadius = 5f, float slowDownRadius = 20f, float timeToDesiredSpeed = 0.1f,
                                                 bool showWhishker = true, float lookAheadLength = 10f, float avoidDistance = 10f, float secondaryWhiskerAngle = 30f, float secondaryWhiskerRatio = 0.7f)
        {
            // give priority to obstacle avoidance
            SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength,
                                                              avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            if (so == null)
            {
                return(Arrive.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed));
            }

            return(so);
        }
        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));
        }
        public static SteeringOutput GetSteering(KinematicState ownKS, Path path, ref int currentWaypointIndex, float wayPointReachedRadius)
        {
            // path shouldn't be neither null nor erroneous
            if (path == null)
            {
                Debug.LogError("PathFollowing invoked with null path");
                return(NULL_STEERING);
            }
            if (path.error)
            {
                Debug.LogError("PathFollowing invoked with null path");
                return(NULL_STEERING);
            }

            // if currentWaypoint is not valid, end of path has been reached
            if (path.vectorPath.Count == currentWaypointIndex)
            {
                return(NULL_STEERING);
            }

            // if we're "close" to the current waypoint try going to the next one
            float distance = (ownKS.position - path.vectorPath[currentWaypointIndex]).magnitude;

            if (distance <= wayPointReachedRadius)
            {
                currentWaypointIndex++;
            }

            if (path.vectorPath.Count == currentWaypointIndex)
            {
                return(NULL_STEERING);
            }

            SURROGATE_TARGET.transform.position = path.vectorPath[currentWaypointIndex];

            if (currentWaypointIndex == path.vectorPath.Count - 1)
            {
                // use arrive for the last waypoint
                return(Arrive.GetSteering(ownKS, SURROGATE_TARGET, wayPointReachedRadius / 2, wayPointReachedRadius * 2));
            }
            else
            {
                return(Seek.GetSteering(ownKS, SURROGATE_TARGET));
            }
        }
Beispiel #10
0
        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);
        }