void SetupDefaultFlock() { for (int i = 0; i < mNumOfBoids; i++) { GameObject newAgent = Instantiate(mBoidPrefab, new Vector3(Random.Range(18f, 22f), Random.Range(18f, 22f), Random.Range(18f, 22f)), Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360))); newAgent.name = "Boid " + i; newAgent.transform.parent = mAgentContainer.transform; TestBoid agentScript = newAgent.GetComponent <TestBoid>(); agentScript.SetManager(this); agentScript.SetShouldFlock(true); AddBoid(agentScript); agentScript.SetTarget(mFlockTarget.transform.position); } }
public void AddBoid(TestBoid argBoid) { if (argBoid == null) { return; } if (!mBoids.Contains(argBoid)) { mBoids.Add(argBoid); } if (argBoid.GetTarget() != mFlockTarget.transform.position) { argBoid.SetTarget(mFlockTarget.transform.position); } }