// Start is called before the first frame update void Start() { // Wait for evaluation metrix to initialize first Evaluation evalScript = GameObject.Find("Evaluation").GetComponent <Evaluation>(); string evalType = evalScript.GetEvalType(); Debug.Log(evalType); if (evalType == "advanced") { evalAdvanced = true; } else if (evalType == "advanced_triangulate") { evalAdvanced = true; evalTriangulate = true; } // Define the world boundary based on camera projection X_LENGTH = 2 * main_camera.orthographicSize * Screen.width / Screen.height; Y_LENGTH = 2 * main_camera.orthographicSize; // Number of particles is the amount of particles that can cover the map NUM_PARTICLES = (int)X_LENGTH * (int)Y_LENGTH; // Set random seed Random.InitState(SEED); // Set initial position _agentPosition = transform.position; // Get Lidar script _lidar_script = GetComponent <Lidar>(); _lidar_precision_radians = _lidar_script.GetLidarPrecisionRadians(); // Initialize particles _beliefStates = new GameObject[NUM_PARTICLES]; _weights = new float[NUM_PARTICLES]; _particleParent = new GameObject(); _particleParent.name = gameObject.name + "_particleParent"; for (int i = 0; i < (int)X_LENGTH; i++) { for (int j = 0; j < (int)Y_LENGTH; j++) { float x = i - (int)X_LENGTH / 2; float y = j - (int)Y_LENGTH / 2; GameObject particle = Instantiate(particlePrefab, new Vector3(x, y, -2), Quaternion.identity); particle.transform.SetParent(_particleParent.transform); _beliefStates[i + j * (int)X_LENGTH] = particle; _weights[i + j * (int)X_LENGTH] = 0.01f; } } // Create belief position _beliefPosition = Instantiate(beliefPositionPrefab, new Vector3(0, 0, -2), Quaternion.identity); _beliefPosition.GetComponent <Renderer>().materials = GetComponent <Renderer>().materials; // Find other agents for cooperative localization _agents = GameObject.FindGameObjectsWithTag("agents"); }