i have a cube mesh which is scaled 500, 50 , 1 and placed at a certain point as in the picture.
what i want to do is Instantiate an object within that cube.
This is so i can generate my game player objects within a certain zone,
how is the best way to do this. This is what i have but not seam to work correcly
Vector3 lMin = lRandomObject.GetComponent().mesh.bounds.min;
Vector3 lMax = lRandomObject.GetComponent().mesh.bounds.max;
Vector3 lLerp = Vector3.Lerp(lMin, lMax, Random.Range(0.2f, 0.8f));
Vector3 lScale = lRandomObject.transform.localScale;
Vector3 lMulti = new Vector3(lLerp.x * lScale.x, lLerp.y * lScale.y, lLerp.z * lScale.z);
Vector3 lAdded = lMulti + lRandomObject.transform.position;
return lAdded;