// Start is called before the first frame update void Start() { int mapsize = 90; //Values are squared this is because they are used to compare values not caluclate, if calculating would involve calculating vector 2 magnitude which would need the values to be square rooting so just saving time squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; //initialize basic variables Collider2D[] hitColliders; Vector2 pos; //Loops through from 0 to the initial starting count of the variables which are flock members for (int i = 0; i < startingCount; i++) { do { //create a random position within the map size and checks that there is overlap with a collider. pos = new Vector2(Random.Range(-mapsize, mapsize), Random.Range(-mapsize, mapsize)); hitColliders = Physics2D.OverlapCircleAll(pos, 1, 1); } while (hitColliders.Length > 0); //when no overlap happens a agent of the flock is created at that positions ,a random rotation and is set as a child of the flock. FlockAgent newAgent = Instantiate( agentPrefab, pos, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform); newAgent.name = "Agent " + i; newAgent.Initialize(this); agents.Add(newAgent); } }
// Start is called before the first frame update void Start() //Init Flock { if (PSO == true) //Kalo PSO dinyalain { PSOInit(); } behaviorMono = new CompositeMono(); //behaviorMono.behaviors = new FlockBehaviorMono[4]; //behaviorMono.weights = new float[4]; //partic = ParticleProgram(); squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidRadius = squareNeighborRadius * avoidRadiusMultiplier * avoidRadiusMultiplier; for (int i = 0; i < startingFlock; i++)// instantiate agent buat agent ke game { FlockAgent newAgent = Instantiate( agentPrefab, Random.insideUnitCircle * startingFlock * AgentDensity, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform); newAgent.name = "Agent" + i; newAgent.Initialize(this); agents.Add(newAgent); } }
private void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; squareSmallRadius = squareNeighborRadius * smallRadiusMultiplier * smallRadiusMultiplier; //Loops for startingCount times of agents for (int i = 0; i < startingCount; i++) { //Instantiate = makes a duplicate of an object or a prefab //Random.insideUnitCircle returns random point inside a circle, number from startingCount * AgentDensity //Quaternion.Euler() converts x/y/z to 2D random rotation //Quaternion.Euler(Vector3.forward * Random.Range(0,360f)) FlockAgent newAgent = Instantiate( agentPrefab, Random.insideUnitCircle * startingCount * AgentDensity, Quaternion.Euler(Vector3.forward * Random.Range(0, 360f)), transform //child of transform game object ); newAgent.name = "Agent" + i; //change name of agent newAgent.Initialize(this); //this is the flock newAgent is a part of agents.Add(newAgent); } }
// Start is called before the first frame update void Start() { if (ChooseDifficulty.difficulty == 0) { startingCount = 5; } else if (ChooseDifficulty.difficulty == 1) { startingCount = 10; } else if (ChooseDifficulty.difficulty == 2) { startingCount = 15; } spawnPosition = gameObject.transform.position; squareMaxSpeed = maxSpeed * maxSpeed; squareNeighbourRadius = neighbourRadius * neighbourRadius; squareAvoidanceRadius = squareNeighbourRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate(agentPrefab, spawnPosition, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), transform); newAgent.name = "Agent" + i; newAgent.Initialize(this); agents.Add(newAgent); } }
public void Start() { //Setup Prefs dataStorage.SetupFlockPrefs(); dataStorage.SetupPredPrefs(); //Check if first time setup if (PlayerPrefs.GetInt("startingCount", 0) == 0) { dataStorage.SaveFlockPrefs(); dataStorage.SavePredPrefs(); } float radius = flock.startingCount * flock.agentDensity * 5; //Spawn in the predator away from murmuration Vector3 predatorPos = Random.insideUnitSphere * flock.startingCount * flock.agentDensity * 5 * 4; float predRadius = radius * 2; while ((predatorPos.x < predRadius && predatorPos.x > predRadius * -1) || (predatorPos.z < predRadius && predatorPos.z > predRadius * -1) || (predatorPos.y < predRadius && predatorPos.y > predRadius * -1)) { predatorPos = Random.insideUnitSphere * flock.startingCount * flock.agentDensity * 5 * 4; } predatorPos += flock.focalPoint; predatorAgent = Instantiate( predatorPrefab, predatorPos, Random.rotation, transform ); predatorAgent.name = "Predator"; predatorAgent.Initialize(flock); flock.predatorAgent = predatorAgent; //Spawn in the flock of birds for (int i = 0; i < flock.startingCount; i++) { Vector3 pos = (Random.insideUnitSphere * flock.startingCount * flock.agentDensity * 5) + flock.focalPoint; FlockAgent starling = Instantiate( flockAgent, pos, Random.rotation, transform ); starling.name = "" + i; starling.Initialize(flock, predatorAgent); flock.agents.Add(starling); flock.agentsTransform.Add(starling.transform); StartCoroutine(starling.starlingAnimate(starling.GetComponentInChildren <Animator>())); grid.Populate(i, pos); } //Setup Camera cam = Instantiate(camPrefab, flock.focalPoint, camPrefab.transform.rotation); cam.Initialise(flock, flock.agents[0].transform, flock.agents[0].transform, predatorAgent.transform); Menu.runSimulation = true; }
public void updatePopulation() { //if number fish in our species is less than the number the model provided if (population < m_targetNumber) { //find how many fish we are off by int popDifference = m_targetNumber - population; //and create that many fish for (int y = 0; y < popDifference; y++) { FlockAgent newAgent = Instantiate( m_FlockAgent, m_AIManager.RandomPosition(), Quaternion.Euler(UnityEngine.Random.Range(-20, 20), UnityEngine.Random.Range(0, 360), 0), transform); newAgent.name = "Agent " + agents.Count; newAgent.Initialize(this); agents.Add(newAgent); } } //or we remove fish as long as we have too many else { while (population > m_targetNumber) { var target = m_FlockAgent.GetComponentInChildren <Transform>(); Destroy(target.GetChild(target.childCount - 1).gameObject); // kill youngest child agents.RemoveAt(target.childCount - 1); } } }
void Start() { // Use square parameters to enhance performance. squareMaxSpeed = maxSpeed * maxSpeed; squareNeighbourRadius = neighbourRadius * neighbourRadius; squareAvoidanceRadius = squareNeighbourRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; // Instantiate the flock. for (int i = 0; i < startingCount; i++) { // Create a circle with the correct alignment in 3D space: assign the y value of the 2D circle to the z axis. Vector3 spawnCircle = Random.insideUnitCircle * startingCount * AgentDensity; newPosition = new Vector3(spawnCircle.x, 0, spawnCircle.y) + transform.position; // Instantiate the agents inside the circle, with a random y rotation. FlockAgent newAgent = Instantiate( agentPrefab, newPosition, //Random.insideUnitCircle * startingCount * AgentDensity, Quaternion.Euler(Vector3.up * Random.Range(0, 360f)), transform ); newAgent.name = "Agent" + i; newAgent.Initialize(this); agents.Add(newAgent); } }
// Start is called before the first frame update IEnumerator Start() { //sqrNeighbourRadius = Mathf.Pow(neighbourRadius, 2); sqrAvoidanceRadius = Mathf.Pow(avoidanceRadius, 2); //Spawn Leader flockLeader = Instantiate( flockLeaderPrefab, transform.position, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform); flockLeader.GetComponent <FlockLeaderController>().waypoints = waypoints; //set waypoints of target leader flockLeader.GetComponent <FlockLeaderController>().Spawn = spawnpoint; flockLeader.GetComponent <FlockLeaderController>().SpawnDestination = spawnDestination; //Spawn all swarm agents for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate( agentPrefab, transform.position + Random.insideUnitSphere * startingCount * agentDensity, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform); newAgent.name = "Agent" + i; newAgent.Initialize(this); agents.Add(newAgent); yield return(null); } //Look for player player = GameObject.FindGameObjectWithTag("Player"); //StartCoroutine(DestroySwarm()); }
// Start is called before the first frame update void Start() { InitLight(); squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; for (int i = 0; i < startingCount; i++) { Vector3 newPosition = new Vector3(Random.Range(spawnPoint.transform.position.x - startingCount, spawnPoint.transform.position.x + startingCount), 1f, Random.Range(spawnPoint.transform.position.z - startingCount, spawnPoint.transform.position.z + startingCount)); //newPosition.z = Random.Range(-10,10); FlockAgent newAgent = Instantiate( agentPrefab, newPosition, Quaternion.Euler(Vector3.forward), transform ); newAgent.name = "Agent " + i; if (i == 0) { newAgent.GetComponent <PoliceAbilities>().EnableFiringSquad(); } if (SpotLightOnAgentO && i == 0) { newAgent.GetComponent <PoliceAbilities>().equipLamp(); } newAgent.Initialize(this); agents.Add(newAgent); } }
} //***** private void Start() { #region Initialize Utility Variable Values squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; squareEvadeRadius = squareNeighborRadius * evadeRadiusMultiplier * evadeRadiusMultiplier; //***** #endregion #region Initialize and Instantiate the Flock for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate( //spawn clones of gameObject or Prefabs agentPrefab, //The Spawned Object Random.insideUnitCircle * startingCount * AgentDensity, //a circle based on density of flock //Spawn location, a random position within a circle of 1 radious, multiplied by the number of Agents and their AgentDensity to make the location large enough to fit all agents relative to density. Quaternion.Euler(Vector3.forward * Random.Range(0, 360f)), //A rotation value between 0-360, rotating on z axis like a clock //Requires a 4 value rotation to face, we use Euler Quaternion to do this, with the z rotation of between 0 and 360 degrees transform //the parent location, this flocks transform ); newAgent.name = "Agent " + i; //each one named agent index newAgent.Initialize(this); //So the agent itself knows what flock it belongs to. agents.Add(newAgent); //add it to the list array of agents } #endregion }
void OnEnable() { if (this.gameObject.tag == "FlockGood") { startingCount = GoodCellstartingCount; } Debug.Log(startingCount + " this is StartingCount"); win = false; lose = false; endGame = false; timer = 5; squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate( agentPrefab, Random.insideUnitCircle * startingCount * AgentDensity * Random.Range(-size, size), Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform ); newAgent.name = "Agent " + i; newAgent.Initialize(this); agents.Add(newAgent); newAgent.gameObject.SetActive(true); } }
// Start is called before the first frame update void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate( agentPrefab, Random.insideUnitSphere * startingCount * AgentDensity, Quaternion.Euler(Vector3.one * Random.Range(0f, 360f)), transform ); newAgent.name = "Agent " + i; newAgent.Initialize(this); agents.Add(newAgent); } if (behavior is CompositeBehavior) { var cbs = ((CompositeBehavior)behavior).behaviors; foreach (var b in cbs) { if (b is StayInRadiusBehavior) { this.stayInsideRadius = ((StayInRadiusBehavior)b).radius; this.stayInsideCenter = ((StayInRadiusBehavior)b).center; break; } } } }
// Use this for initialization void Start() { rb = GetComponent <Rigidbody2D>(); squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; status = Status.Flocking; // Create flock for (int i = 0; i < startingCount; ++i) { float x = Random.Range(-5f, 5f); float y = Random.Range(-5f, 5f); Vector2 pos = new Vector2(x, y); FlockAgent agent = Instantiate ( agentPrefab, Random.insideUnitCircle * startingCount * AgentDensity, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform ); agent.Initialize(this); agents.Add(agent); } myPosition = gameObject.transform.position; }
protected virtual void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; squareSmallRadius = squareNeighborRadius * smallRadiusMultiplier * smallRadiusMultiplier; //loops for startingCount times. creates StratingCount amount of agents on game start. for (int i = 0; i < startingCount; i++) { var xz = Random.insideUnitCircle * startingCount * AgentDensity; var newSpawn = new Vector3(xz.x, xz.y) + transform.position; //create a new agent (the agent is the AI) FlockAgent newAgent = Instantiate( //instantiate creates a clone of a gameobject or prefab agentPrefab, //this is the prefab being cloned newSpawn, // give in a random position within a circle Quaternion.Euler(Vector3.forward * Random.Range(0, 360f)), //give it a random rotation transform //this transform is the parent of the new AI agent ); newAgent.name = "Agent " + i; newAgent.Initialize(this); agents.Add(newAgent); } }
public void Add(Transform destination) { FlockAgent newAgent = Instantiate( agentPrefab, destination.position, destination.rotation, transform ); newAgent.name = "Agent takover"; newAgent.Initialize(this); agents.Add(newAgent); }
void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate(agentPrefab, Random.insideUnitCircle * startingCount * agentDensity, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform); newAgent.name = "Agent " + i; newAgent.Initialize(this); agents.Add(newAgent); } }
public void AddAgent(Vector2 pos) { FlockAgent newAgent = Instantiate( // Instantiate generates new gameObjects at runtime via prefabs agentPrefab, new Vector3(pos.x, pos.y, 0), // Agent position Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), // Agent orientation transform // Agent's parent (The flock transform) ); newAgent.name = "Agent " + agents.Count; newAgent.Initialize(this); agents.Add(newAgent); }
void InstantiateLeader(Color leaderColor, bool isPlayer, int id, Vector2 center) { FlockAgent leaderAgent = Instantiate( agentLeaderPrefab, center, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform ); leaderAgent.GetComponentInChildren <Renderer>().material.SetColor("_Color", leaderColor); leaderAgent.name = "Leader Agent " + id; leaderAgent.Initialize(this, isPlayer, id, "Leader"); agents.Add(leaderAgent); }
IEnumerator Reinforcement(FlockAgent agent) { while (!agent.navMeshAgent) { yield return(new WaitForFixedUpdate()); } agent.navMeshAgent.destination = AveragePositionOfFlock(); agent.navMeshAgent.speed = 40f; while ((agent.transform.position - agent.navMeshAgent.destination).magnitude <= 2.0f) { yield return(new WaitForFixedUpdate()); } agents.Add(agent); agent.Initialize(this); newAgents.Remove(agent); yield return(null); }
public void OnSpacebarPressed(Transform position) { for (int i = 0; i < spawnNumberWhenPressed; i++) { FlockAgent newAgent = Instantiate( agentPrefab, //what to instantiate position.position + new Vector3(Random.Range(-spawnOffset, spawnOffset), Random.Range(-spawnOffset, spawnOffset)), //where its located at --CHANGE Quaternion.identity, transform //transform as parent ); newAgent.name = "Agent"; newAgent.Initialize(this); agents.Add(newAgent); Debug.Log("Added Agents"); } }
public void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate(agentPrefab, new Vector3(Random.insideUnitSphere.x, 0, Random.insideUnitSphere.z) * startingCount * AGENT_DENSITY, Quaternion.Euler(Vector3.up * Random.Range(0f, 360f)), transform); newAgent.name = "agent" + i; newAgent.Initialize(this); agents.Add(newAgent); } }
public void GenerateAgents(int count) { int originalCount = agents.Count; //Crée tous les poissons et donne les noms for (int i = 0; i < count; i++) { FlockAgent newAgent = Instantiate( agentPrefab, Random.insideUnitSphere * startingCount * AgentDensity + transform.position, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform ); newAgent.name = "Agent" + (i + originalCount); newAgent.Initialize(this); agents.Add(newAgent); } }
void Start() { squareNeighbourRadius = neighbourRadius * neighbourRadius; for (int i = 0; i < startingCount; i++) { Vector2 startPos = Random.insideUnitCircle * startingCount * agentDensity; FlockAgent newAgent = Instantiate( agentPrefabs[Random.Range(0, agentPrefabs.Count)], new Vector3(startPos.x + this.transform.position.x, this.transform.position.y, startPos.y + this.transform.position.z), Quaternion.Euler(Vector3.up * Random.Range(0, 360)), this.transform ); newAgent.name = "Agent " + i; newAgent.Initialize(this); agents.Add(newAgent); } }
void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate(agentPrefab); newAgent.transform.position = Random.insideUnitSphere * startingCount * AgentDensity; newAgent.transform.rotation = Random.rotation; newAgent.transform.SetParent(transform, false); Debug.Log(newAgent.transform.forward); newAgent.name = string.Format("Agent {0}", i); newAgent.Initialize(this); agents.Add(newAgent); } }
// Start is called before the first frame update void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRad = neighborRad * neighborRad; squareAvoidanceRad = squareNeighborRad * avoidanceRadMultiplier * avoidanceRadMultiplier; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate( agentPrefab, (Random.insideUnitSphere * startingCount * AgentDensity * spawnSize) + transform.position, Quaternion.Euler(Vector3.up * Random.Range(0f, 360f)), transform ); newAgent.name = "Agent " + i; newAgent.Initialize(this); agents.Add(newAgent); } }
public float colorLerpDivider = 6f; //The multiplier/divider used to calculate the Lerp rate for the gradient color effect #endregion #region Default void Start() { #region Square Setups //set up the squared values to be correct squareMaxSpeed = maxSpeed * maxSpeed; //max speed squareNeighbourRadius = neighbourRadius * neighbourRadius; //neighbourRadius squareAvoidanceRadius = squareNeighbourRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; //avoidance radius (kinda). 0.5 times bigger than neighbourRadius #endregion #region Setup each agent for (int i = 0; i < startingCount; i++) //For each agent in our flock { FlockAgent newAgent = Instantiate(agentPrefab, Random.insideUnitCircle * startingCount * AgentDensity, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform); //Create an agent prefab object within the scene at the correct position newAgent.Initialize(this); //Set up the agent with the FlockAgent script newAgent.name = "Agent " + 1; //Name it to its numarical correspondance agents.Add(newAgent); //Add a new agent to the list of agents for use later } #endregion }
// Start is called before the first frame update void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = UIDataAccessor.Instance.GetGroupingForceData().radius; squareAvoidanceRadius = UIDataAccessor.Instance.GetCollisionAvoidanceData().minDistance; squareObstacleRadius = UIDataAccessor.Instance.GetObstacleAvoidanceData().radius; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate( agentPrefab, Random.insideUnitCircle * startingCount * AgentDensity, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform ); newAgent.name = "Agent " + i; newAgent.Initialize(this); agents.Add(newAgent); } }
void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighborRadius = neighborRadius * neighborRadius; squareAvoidanceRadius = squareNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; avoidanceRadius = neighborRadius * avoidanceRadiusMultiplier; for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate( agentPrefab, Random.insideUnitSphere * startingCount * AgentDensity, Random.rotation, transform ); newAgent.name = string.Format("Agent {0}", i); newAgent.Initialize(this); agents.Add(newAgent.name, newAgent); } }
void Start() { squareMaxSpeed = maxSpeed * maxSpeed; squareNeighbourRadius = neighbourRadius * neighbourRadius; squareAvoidanceRadius = squareNeighbourRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier; // populate the scene with agent for (int i = 0; i < startingCount; i++) { FlockAgent newAgent = Instantiate( agentPrefab, // type of agent Random.insideUnitSphere / 8f * startingCount * AgentDensity + flockSpawnPoint, // place it somewhere inside a unit sphere with the Quaternion.Euler(Vector3.left * Random.Range(0f, 360f)), // random rotation transform // set parent to the empty game object Flock ); newAgent.name = "agent " + i; newAgent.fieldOfView = agentFieldOfView; newAgent.Initialize(this); agents.Add(newAgent); // add agent to list to keep track of } }
void InstantiateFlock(Vector2 center, Color flockColor, int id, int spawnCount, float spawnRadius, bool leader) { for (int i = 0; i < spawnCount - 1; i++) { FlockAgent newAgent = Instantiate( agentBasicPrefab, Random.insideUnitCircle * spawnCount * spawnRadius + center, Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)), transform ); newAgent.name = "Basic Agent "; newAgent.Initialize(this, false, 0, "Basic"); agents.Add(newAgent); } bool player = id == 1 ? true : false; if (leader) { InstantiateLeader(flockColor, player, id, center); } }