/// <summary> /// Initializes the spaceman and helmet. /// </summary> private void InitializeSpacemanAndHelmet() { // Position spaceman and helmet on opposite ends of the screen (left or right) Vector2 min = Locator.GetSceneMaster().UICamera.ScreenMinWorld; Vector2 max = Locator.GetSceneMaster().UICamera.ScreenMaxWorld; Vector3 leftPos = new Vector3(Random.Range(min.x + m_spawnOffsetFromScreenEdge, min.x + m_spacemanAndHelmetSpawnRange), Random.Range(min.y + m_spawnOffsetFromScreenEdge, max.y - m_spawnOffsetFromScreenEdge)); Vector3 rightPos = new Vector3(Random.Range(max.x - m_spawnOffsetFromScreenEdge, max.x - m_spacemanAndHelmetSpawnRange), Random.Range(min.y + m_spawnOffsetFromScreenEdge, max.y - m_spawnOffsetFromScreenEdge)); // Randomly choose which side each of the two will be placed bool isSpacemanOnLeft = Random.value > 0.5f; m_spaceman.transform.position = isSpacemanOnLeft ? leftPos : rightPos; m_helmet.transform.position = isSpacemanOnLeft ? rightPos : leftPos; // Make spaceman face the side where the helmet is m_spaceman.transform.SetScaleX(isSpacemanOnLeft ? 1.0f : -1.0f); // Randomize spaceman's starting rotation m_spaceman.AnimRoot.SetRotZ(Random.Range(0.0f, 360.0f)); AddToAnimatorList(m_spaceman.AnimRoot.GetComponent <Animator>()); // Initialize m_spaceman.Initialize(this); m_helmet.Initialize(); }