void Start() { spline = new CatmulRomSpline3D(); Vector3[] cps = new Vector3[8]; //initialize 8 points cps[0] = new Vector3(-3, 4, -3); cps[1] = new Vector3(-3, 4, 3); cps[2] = new Vector3(3, 4, 3); cps[3] = new Vector3(3, 4, -3); cps[4] = cps[0]; cps[5] = cps[1]; cps[6] = cps[2]; cps[7] = cps[3]; spline.control_points = cps; sampleTable = spline.getSampleTimes(sampleNum); curr_t = 0; object_list = new List <GameObject>(); for (int i = 0; i < 50; ++i) { GameObject boid = Instantiate(follower_boid); Vector3 relative_pos = new Vector3( (Random.value - 0.5f) * 2 * followRadius, (Random.value - 0.5f) * 2 * followRadius, (Random.value - 0.5f) * 2 * followRadius ); // SetParent(gameObject,boid); boid.name = "Object No." + i; boid.transform.position = gameObject.transform.position + relative_pos; object_list.Add(boid); } }
// Use this for initialization void Start() { spline = new CatmulRomSpline3D(); spline.control_points = cps; current_t = 0; Boids = new GameObject[FlockSize]; for (int i = 0, k = -1; i < FlockSize; i++) { if (i % 10 == 0) { k++; } Vector3 position = new Vector3((i % 10) * 4, 60 + (k * 4), 10); GameObject boid = Instantiate(Seagull, transform.position, transform.rotation) as GameObject; boid.transform.localPosition = position; Boids[i] = boid; } BoidToAttack = 0; }