# My runtime mesh is not being created where it's vertices are located, need help

I'm trying to create a quad at runtime and I'm encountering an issue where the mesh does not show up in the scene where it's vertices where set. In the following picture you can see the ship, and to the far right the mesh.

The 4 white dots around the ship where drawn after the mesh was made using the 4 vertices of the mesh.

My Code:

//Handles the method calls for the mesh creation
private void BoundingMeshCreation()
{
Quaternion currentRotation = ResetPosition(new Quaternion(0, 0, 0, 0));
BoundingPointsType boundingPoints = DetermineBounds();
Mesh boundingMesh = CreateBoundingMesh(boundingPoints);
AssignMesh(boundingMesh);
ResetPosition(currentRotation);
}

//Creates the mesh filter and assigns the mesh
private void AssignMesh(Mesh boundingMesh)
{
newMeshFilter.mesh = boundingMesh;

VectorLine testPoint = new VectorPoints("testPoint", boundingMesh.vertices, null, 5);
testPoint.Draw3D();
}

//Creates a bounding mesh for the unit
private Mesh CreateBoundingMesh(BoundingPointsType boundingPoints)
{

Mesh boundingMesh = new Mesh();

Vector3[] vertices = new Vector3[4]
{
boundingPoints.LowerLeftPoint,
boundingPoints.LowerRightPoint,
boundingPoints.UpperRightPoint,
boundingPoints.UpperLeftPoint
};

int[] triangles = new int[6]
{
0,
2,
1,

0,
3,
2
};

boundingMesh.vertices = vertices;
boundingMesh.triangles = triangles;

return boundingMesh;
}

//Resets the units rotation to the specific quaternion and returns the quaterion from before the reset. Bit of a hack for now to make sure that the original box is the proper size.
private Quaternion ResetPosition(Quaternion toResetTo)
{
Quaternion currentRotation = transformV.rotation;
transformV.rotation = toResetTo;
return currentRotation;
}

//Determines and returns the bounding box points
private BoundingPointsType DetermineBounds()
{
Vector3 maxBounds = childSprite.GetComponent<Renderer>().bounds.max;
Vector3 minBounds = childSprite.GetComponent<Renderer>().bounds.min;

BoundingPointsType boundingPoints = new BoundingPointsType(new Vector3(maxBounds.x, 1, maxBounds.z),
new Vector3(minBounds.x, 1, maxBounds.z),
new Vector3(maxBounds.x, 1, minBounds.z),
new Vector3(minBounds.x, 1, minBounds.z));
return boundingPoints;
}


I've even tried manually setting the vertices like the following:

    Vector3 UpRight = transformV.position;
Vector3 UpLeft = transformV.position;
Vector3 LowRight = transformV.position;
Vector3 LowLeft = transformV.position;

UpRight.z += 1;
UpRight.x += 1;

UpLeft.z += 1;
UpLeft.x -= 1;

LowRight.z -= 1;
LowRight.x += 1;

LowLeft.z -= 1;
LowLeft.x -= 1;

Vector3[] vertices = new Vector3[4]
{
LowLeft,
LowRight,
UpRight,
UpLeft
//boundingPoints.LowerLeftPoint,
//boundingPoints.LowerRightPoint,
//boundingPoints.UpperRightPoint,
//boundingPoints.UpperLeftPoint
};


I'm at a loss, and have no idea what I'm doing wrong. My dynamic meshes seem to work perfectly fine for everything else in the game.

Thanks.

Vector3 maxBounds = transform.InverseTransformPoint(childSprite.GetComponent<Renderer>().bounds.max);