void ChangeLane() { Vector3 newPos = transform.position; newPos.y = Lanes.GetLane(LaneNo).transform.position.y; SpriteOrderSetter orderSetter = new SpriteOrderSetter(GetComponent <SpriteRenderer>(), GetLaneNo()); transform.position = newPos; }
void SpawnObstacles() { if (!rollForSpawn(obsSpawnChance)) { return; } int lanePosition = RollLane(); int objType = RollObjType(ObstacleManager.Manager.ObjectTypes.Count); obstacle = ObstacleManager.Manager.GetObject(objType); if (obstacle == null) { obstacle = Instantiate(ObstacleManager.Manager.ObjectTypes[objType], Vector2.zero, Quaternion.identity); ObstacleManager.Manager.AddObject(obstacle); } obstacle.transform.position = new Vector2(ObjSpawnPoint.position.x, Lanes.GetLane(lanePosition).transform.position.y); obstacle.LaneNo = lanePosition; obstacle.ChangeOrder(); }