void Start() { // Set santa to player. santa = GameObject.FindGameObjectWithTag("Player").GetComponent <Santa>(); // Set the chimney spawner to spawner spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <ChimneySpawner>(); }
// Randomize height and position top // at start. void Start() { BoxCollider2D chimneyCollide = GetComponent <BoxCollider2D>(); float newHeight = Random.Range(0.15f, 1f) * 4.5f; chimneyCollide.size = new Vector2(1f, newHeight); chimneyCollide.offset = Vector2.up * newHeight / 2; ChimneyTop.GetComponent <Transform>().localPosition = Vector3.up * (newHeight + 0.25f); // Set santa to player santa = GameObject.FindGameObjectWithTag("Player").GetComponent <Santa>(); spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent <ChimneySpawner>(); }