Ejemplo n.º 1
0
        // Use this for initialization
        IEnumerator Start()
        {
            yield return(null);

            for (int i = 0; i < agents; i++)
            {
                float angle = ((float)i / agents) * (float)System.Math.PI * 2;

                Vector3 pos       = new Vector3((float)System.Math.Cos(angle), 0, (float)System.Math.Sin(angle)) * ringSize;
                Vector3 antipodal = -pos + goalOffset;

                GameObject      go = GameObject.Instantiate(prefab, Vector3.zero, Quaternion.Euler(0, angle + 180, 0)) as GameObject;
                RVOExampleAgent ag = go.GetComponent <RVOExampleAgent>();

                if (ag == null)
                {
                    Debug.LogError("Prefab does not have an RVOExampleAgent component attached");
                    yield break;
                }

                //ag.radius = radius;
                go.transform.parent   = transform;
                go.transform.position = pos;

                ag.repathRate = repathRate;
                ag.SetTarget(antipodal);

                ag.SetColor(GetColor(angle));
            }
        }
Ejemplo n.º 2
0
		private IEnumerator Start()
		{
			yield return null;
			for (int i = 0; i < this.agents; i++)
			{
				float num = (float)i / (float)this.agents * 3.14159274f * 2f;
				Vector3 vector = new Vector3((float)Math.Cos((double)num), 0f, (float)Math.Sin((double)num)) * this.ringSize;
				Vector3 target = -vector + this.goalOffset;
				GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.prefab, Vector3.zero, Quaternion.Euler(0f, num + 180f, 0f));
				RVOExampleAgent component = gameObject.GetComponent<RVOExampleAgent>();
				if (component == null)
				{
					Debug.LogError("Prefab does not have an RVOExampleAgent component attached");
					yield break;
				}
				gameObject.transform.parent = base.transform;
				gameObject.transform.position = vector;
				component.repathRate = this.repathRate;
				component.SetTarget(target);
				component.SetColor(this.GetColor(num));
			}
			yield break;
		}