public static SteeringOutput GetSteering(KinematicState ownKS, GameObject repulsor, float scareRadius = 40f, float fleeWeight = 0.2f, string idTag = "BOID", float cohesionThreshold = 40f, float repulsionThreshold = 10f, float wanderRate = 10f) { SteeringOutput fleeOutput; if ((ownKS.position - repulsor.transform.position).magnitude <= scareRadius) { fleeOutput = Flee.GetSteering(ownKS, repulsor); } else { fleeOutput = NULL_STEERING; } SteeringOutput result = Flocking.GetSteering(ownKS, idTag, cohesionThreshold, repulsionThreshold, wanderRate); // beware, Flocking may return NULL_STEERING. In that case, just apply flee if (result == NULL_STEERING) { return(fleeOutput); } result.linearAcceleration = result.linearAcceleration * (1 - fleeWeight) + fleeOutput.linearAcceleration * fleeWeight; result.angularAcceleration = result.angularAcceleration * (1 - fleeWeight) + fleeOutput.angularAcceleration * fleeWeight; return(result); }
private static KinematicState surrogateKS; // kinematic state for surrogate target public override SteeringOutput GetSteering() { // no KS? get it if (this.ownKS == null) { this.ownKS = GetComponent <KinematicState>(); } return(Flocking.GetSteering(this.ownKS, idTag, cohesionThreshold, repulsionThreshold, wanderRate)); }
/* other weight configurations: * - 0.1 0.3 0.2 0.4 * - 0.1 0.25 0.25 0.4 * - 0.2 0.4 0.3 0.1 * * Generally a low vm is enough. * Generally rp must be higher than co and the rest, otherwise boids touch each other * */ public override SteeringOutput GetSteering() { // no KS? get it if (this.ownKS == null) { this.ownKS = GetComponent <KinematicState>(); } SteeringOutput result = Flocking.GetSteering(this.ownKS, idTag, cohesionThreshold, repulsionThreshold, wanderRate, vmWeight, rpWeight, coWeight, wdWeight); base.applyRotationalPolicy(rotationalPolicy, result, null); return(result); }
public static SteeringOutput GetSteering(KinematicState ownKS, string idTag, float cohesionsThreshold, float repulsionThreshold, float wanderRate, bool showWhishker, float lookAheadLength, float avoidDistance, float secondaryWhiskerAngle, float secondaryWhiskerRatio) { // give priority to obstacle avoidance SteeringOutput so = ObstacleAvoidance.GetSteering(ownKS, showWhishker, lookAheadLength, avoidDistance, secondaryWhiskerAngle, secondaryWhiskerRatio); if (so == null) { return(Flocking.GetSteering(ownKS, idTag, cohesionsThreshold, repulsionThreshold, wanderRate)); } return(so); }
public static SteeringOutput GetSteering(KinematicState ownKs, string idTag, float cohesionThreshold, float repulsionThreshold, float wanderRate, float vmWeight, float rpWeight, float coWeight, float wdWeight, GameObject target, float distance, float angle, float kpWeight) { SteeringOutput fl = Flocking.GetSteering(ownKs, idTag, cohesionThreshold, repulsionThreshold, wanderRate, vmWeight, rpWeight, coWeight, wdWeight); SteeringOutput kp = KeepPosition.GetSteering(ownKs, target, distance, angle); if (kp == NULL_STEERING) { return(fl); } fl.linearAcceleration = fl.linearAcceleration * (1 - kpWeight) + kp.linearAcceleration * kpWeight; // fl.linearAcceleration = fl.linearAcceleration.normalized * ownKs.maxAcceleration; return(fl); }
public static SteeringOutput GetSteering(KinematicState ownKS, GameObject attractor, float seekWeight = 0.2f, string idTag = "BOID", float cohesionThreshold = 40f, float repulsionThreshold = 10f, float wanderRate = 10f, float vmWeight = 0.08f, float rpWeight = 0.46f, float coWeight = 0.23f, float wdWeight = 023f) { SteeringOutput seekOutput = Seek.GetSteering(ownKS, attractor); SteeringOutput result = Flocking.GetSteering(ownKS, idTag, cohesionThreshold, repulsionThreshold, wanderRate); // beware, Flocking may return NULL_STEERING. In that case, just apply seek if (result == NULL_STEERING) { return(seekOutput); } result.linearAcceleration = result.linearAcceleration * (1 - seekWeight) + seekOutput.linearAcceleration * seekWeight; result.angularAcceleration = result.angularAcceleration * (1 - seekWeight) + seekOutput.angularAcceleration * seekWeight; return(result); }