I have no idea why my code doesn't work. I've tried with all the combinations of game objects and my GameController couses of the problem.
It basicly adds grabber objects inside a circle randomly and tries to make them far from each other.
The code is here (C#):
using UnityEngine;
using System.Collections;
public class GameController : MonoBehaviour {
//public int playerNum = 1;
//public bool classic = true;
public GameObject Grabber;
public float spawnWait=0;
public float startWait=1.5f;
public int maxGrabberNum = 5;
public float minGrabberDist = 2f;
void Start ()
{
StartCoroutine (SpawnGrabbers ());
}
IEnumerator SpawnGrabbers ()
{
yield return new WaitForSeconds (startWait);
while (true)
{
Debug.Log("In da first while loop");
GameObject[] grabbers = GameObject.FindGameObjectsWithTag("Grabber");
if(grabbers.Lengthmgni)
{
dist = mgni;
}
}
Debug.Log("min dist is: "+ dist);
}while(dist
↧