This code creates circle of gameobjects with 3 holes in ( object are not instantiated in these 3 places ).
I want to instantiate another gameobject in places where only holes are. How to do that? This is the code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Walls3 : MonoBehaviour {
public GameObject prefab;
public int numberOfObjects = 20;
public float radius = 5f;
List<int> FindHoles(int totalSegments, int holeCount) {
List<int> holes = new List<int>();
for (int i = 0; i < totalSegments; i++) {
holes.Add(i);
}
while (holes.Count > holeCount) {
holes.RemoveAt (Random.Range (0,holes.Count));
}
return holes;
}
void Start () {
List<int> holes = FindHoles(numberOfObjects, 3);
for (int i = 0; i < numberOfObjects; i++) {
float angle = i * Mathf.PI * 2 / numberOfObjects;
Vector3 pos = new Vector3 (Mathf.Cos (angle), 0, Mathf.Sin (angle)) * radius;
if (!holes.Contains(i)) {
GameObject Wally = Instantiate (prefab, pos, Quaternion.LookRotation(-pos)) as GameObject;
Wally.gameObject.tag = "Wallpart";
Wally.transform.parent = transform;
}
}
}
// Update is called once per frame
void Update () {
}
}