コード例 #1
0
        public override SteeringOutput GetSteering()
        {
            // no KS? get it
            if (this.ownKS == null)
            {
                this.ownKS = GetComponent <KinematicState>();
            }

            return(ArrivePlusAvoid.GetSteering(ownKS, target, closeEnoughRadius, slowDownRadius, timeToDesiredSpeed,
                                               showWhisker, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio));
        }
        public static SteeringOutput GetSteering(KinematicState ownKS, GameObject target, float distance = 10.0f, float slowRadius = 20.0f,
                                                 float disredSpeed = 0.1f, bool showWhishker        = true, float lookAheadLength = 10f, float avoidDistance = 10f, float secondaryWhiskerAngle = 30f, float secondaryWhiskerRatio = 0.7f,
                                                 string tag        = "REPULSIVE", float repulsionTh = 8.0f, float repulsionWeight = 0.5f)
        {
            SteeringOutput linearRepulsion = LinearRepulsion.GetSteering(ownKS, tag, repulsionTh);
            SteeringOutput arrive          = ArrivePlusAvoid.GetSteering(ownKS, target, distance, slowRadius, disredSpeed, showWhishker, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio);

            SteeringOutput result = new SteeringOutput();

            if (linearRepulsion == NULL_STEERING)
            {
                return(arrive);
            }
            else if (arrive == NULL_STEERING)
            {
                return(linearRepulsion);
            }

            result.linearAcceleration = arrive.linearAcceleration * (1 - repulsionWeight) + linearRepulsion.linearAcceleration * repulsionWeight;
            return(result);
        }
コード例 #3
0
ファイル: ArrivePlusAvoid.cs プロジェクト: NoctisRB/Eddy
        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);
        }