# Sweep for vertex positions?

Hi, I wrote a script that would find the position and direction of the vertices of a mesh. How do I do somewhat like a 360 sweep from the player’s position to arrange the positions of vertices from 0 to 360 degrees?

``````function Update ()
{
var wallVerts = target.GetComponent.<MeshFilter>().mesh.vertices;
var wallVertLength = wallVerts.length;

for (var i:int=0;i<wallVertLength;i++)
{

var vertPos = target.transform.TransformPoint(wallVerts*);*
``````

var dir = (vertPos - transform.position).normalized;

I’m also a bit lost on this question. Just sorting the vertices in a circle around one axis won’t help you to generate a proper mesh. Do you have already your triangle list? Do you just want to make a blend-in-animation?

Anyway, sorting (no matter what) requires you to have a value you can sort on. In your case you need the angle from a certain start direction. Since we are in 3D you have to sort around one axis first. So to do the angle calculation i would “project” the direction to an axis aligned plane (x-z-plane for example so you rotate yround the y-axis)

``````import System.Collections.Generic;

class SortVertex
{
var index : int;
var angle : float;
}

static function compare(A : SortVertex, B : SortVertex) : int
{
return A.angle.CompareTo(B.angle);
}

function DoIt()
{
var wallVerts = target.GetComponent.<MeshFilter>().mesh.vertices;
var wallVertLength = wallVerts.length;
var wallVertValues = new List.<SortVertex>(wallVertLength);

for (var i = 0; i < wallVertLength; i++)
{
var vertPos = target.transform.TransformPoint(wallVerts*);*
``````

var dir = (vertPos - transform.position);
dir.y = 0.0f;
dir.Normalize();
var V = Mathf.Atan2(dir.z, dir.x);
var SV = new SortVertex();
SV.index = i;
SV.value = angle;