private GameObject CreateWall(float length, string name, GameObject parent, bool visible = true) { var wall = _assetPool.SpawnTransform(Constants.TAG_WALL).gameObject; wall.GetComponent <Collider>().material = noFrictionMaterial; // +1 to give a buffer on both sides, so the walls superpose at the edges wall.transform.localScale = new Vector3(Constants.DEFAULT_WALL_WIDTH, Constants.DEFAULT_WALL_HEIGHT, length + 1f); wall.transform.parent = parent.transform; wall.name = name; wall.GetComponent <Collider>().material = noFrictionMaterial; if (!visible) { var renderer = wall.GetComponent <Renderer>(); renderer.enabled = false; // Make the invis wall taller wall.transform.localScale += new Vector3(0, Constants.MAX_ENERGY, 0); } return(wall); }