This is my code to crate a quad but as the title says the quad is crated in local space and not world.
Mesh CrateMeshChunk()
{
V1 = Me.transform.position;
V2 = NeighbourTop.transform.position;
V3 = NeighbourLeft.transform.position;
V4 = NeighbourLeft.GetComponent<Neighbour>().NeighbourTop.transform.position;
Mesh mesh = new Mesh();
Vector3[] vertices = new Vector3[]
{
V1,V2,V3,V4,
};
Vector2[] uv = new Vector2[]
{
UV1,UV2,UV3,UV4,
};
int[] triangles = new int[]
{
0, 1, 2,
2, 1, 3,
};
mesh.vertices = vertices;
mesh.uv = uv;
mesh.triangles = triangles;
return mesh;
}
The mesh.vertices are in local space relative to its attached gameObject, maybe you should transform the vertex position from world to local:
V1 = quadTransform.InverseTransformPoint(Me.transform.position);
V2 = quadTransform.InverseTransformPoint(NeighbourTop.transform.position);
V3 = quadTransform.InverseTransformPoint(NeighbourLeft.transform.position);
V4 = quadTransform.InverseTransformPoint(NeighbourLeft.GetComponent<Neighbour>().NeighbourTop.transform.position);
Yword