// Update is called once per frame void Update() { PyramidBuilder pyramidBuilder = new PyramidBuilder(); pyramidBuilder.SetUpSubmeshes(4); MeshFilter meshFilter = this.GetComponent <MeshFilter>(); MeshRenderer meshrenderer = this.GetComponent <MeshRenderer>(); //Add points Vector3 topPoint = new Vector3(0, pyramidSize, 0); Vector3 base0 = Quaternion.AngleAxis(0f, Vector3.up) * Vector3.forward * pyramidSize; Vector3 base1 = Quaternion.AngleAxis(240f, Vector3.up) * Vector3.forward * pyramidSize; Vector3 base2 = Quaternion.AngleAxis(120f, Vector3.up) * Vector3.forward * pyramidSize; //Build Triangles for our pyramid pyramidBuilder.BuildMeshTriangle(base0, base1, base2, 0); pyramidBuilder.BuildMeshTriangle(base1, base0, topPoint, 1); pyramidBuilder.BuildMeshTriangle(base2, topPoint, base0, 2); pyramidBuilder.BuildMeshTriangle(topPoint, base2, base1, 3); meshFilter.mesh = pyramidBuilder.CreateMesh(); pyramidBuilder.AddMaterials(meshrenderer); }