Hello i am trying to make a circular mesh, the problem i encountered seems to be that the vertices do not align properly to form a perfect circle and so i get this. ( i created box primitives at the vertice vec3 locations as i have yet to define the UV’s and Triangles to form the mesh ).
PICTURE:
here is the code i am currently using.
using UnityEngine;
using System.Collections;
public class CreateAsteroid : MonoBehaviour
{
int AsteroidMeshVerticeNumber = 8 ;
int AsteroidMeshRadius = 32;
public Vector3[] AsteroidMeshVertices;
void Start ()
{
gameObject.AddComponent("MeshFilter");
gameObject.AddComponent("MeshRenderer");
Mesh AsteroidMesh = GetComponent<MeshFilter>().mesh;
AsteroidMesh.Clear();
AsteroidMeshVertices = new Vector3[AsteroidMeshVerticeNumber];
for (int i = 0; i < AsteroidMeshVerticeNumber; i++)
{
float _angle = (360 / AsteroidMeshVerticeNumber) * i ;
Debug.Log(_angle);
float _x = Mathf.Cos( _angle ) * AsteroidMeshRadius ;
float _z = Mathf.Sin( _angle ) * AsteroidMeshRadius ;
//Debug.Log(_x);
//Debug.Log(_z);
AsteroidMeshVertices[i] = new Vector3( _x , 0 , _z );
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = new Vector3( _x , 0 , _z );
}
}
}
Thank you for your help!
Dmajster_