// Update is called once per frame void Update() { if (Time.time >= nextSpawnTime) { UpdateSpawnTime(); HasLane spawnedMonster = Instantiate(monster, transform.position, transform.rotation, lanes.transform); spawnedMonster.Lane = lanes.RandomLane(); float yPosition = lanes.CenterOfLane(spawnedMonster.Lane) + Random.Range(-lanePositionJitter, lanePositionJitter) * lanes.LaneHeight; spawnedMonster.transform.position += new Vector3(0, yPosition, 0); } }
private void Reposition() { transform.position = new Vector3(lanes.GetComponent <BoxCollider2D>().bounds.min.x + lanes.LaneHeight / 2f, lanes.CenterOfLane(currentLane.Lane), 0); }