private void CalcSteeringForce() { steeringForce = Vector3.zero; //Keeps werewolves away from Villager Spawn point steeringForce += gameManager.avoidWt * steering.AvoidObstacle(respawnPont, 100f); float mayDist = Vector3.Distance(this.transform.position, gameManager.Mayor.transform.position); //Choose new villager to chase (closest villager) target = gameManager.Villagers[0]; findTarget(); float tarDist = Vector3.Distance(this.transform.position, target.transform.position); if (tarDist > 30) { steeringForce += 10 * steering.Pursuit(target.transform.forward + target.transform.position); } else { steeringForce += 6 * steering.Seek(target); } if (mayDist < 20) { steeringForce += 20 * steering.Flee(gameManager.Mayor); } else { steeringForce += 5 * steering.Evasion(gameManager.Mayor.transform.forward + gameManager.Mayor.transform.position); } //avoid close obstacles for (int i = 0; i < gameManager.Obstacles.Length; i++) { if (Vector3.Distance(this.transform.position, gameManager.Obstacles[i].transform.position) < 60) { steeringForce += gameManager.avoidWt * steering.AvoidObstacle(gameManager.Obstacles[i], gameManager.avoidDist); } } }
public override Vector2 CalculateSteering(Vehicle agent, List <Vehicle> targets) { Vector2 avoidSteering = Steering.AvoidObstacle(agent, innerRadius, outerRadius, Obstacle.AllObstacles); if (avoidSteering != Vector2.zero) { return(avoidSteering); } else { return(Steering.Wander(agent, distance, radius, jilter)); } }