public void addObject() { CollectableObjects o = Instantiate(objects[Random.Range(0, objects.Length)]); o.gameObject.name = o.gameObject.name.Remove(o.gameObject.name.Length - 7); o.transform.position = new Vector3(Random.Range(Mathf.Min(corner1.x, corner2.x), Mathf.Max(corner1.x, corner2.x)), Random.Range(Mathf.Min(corner1.y, corner2.y), Mathf.Max(corner1.y, corner2.y)), Random.Range(Mathf.Min(corner1.z, corner2.z), Mathf.Max(corner1.z, corner2.z))); c.addItem(o); }