kind of ran into to a annoying problem.
I’m have some verts position I want to use to set a direction of a raycast. the ray should hit a plane behind the gameObject i use the verts from.
but my ray stops when it hits the gameobject’s verts. When i put it in a layer to ignore or put the plane in a layer to get hit, it stops casting all together… so I’m thinking i can’t use positions for my ray direction from objects that are being ignored? is that right?
code:
void CreateShadowCollision()
{
for(int i=0; i<puppets.Count; i++)
{
Mesh mesh = puppets[i].GetComponent<MeshFilter>().sharedMesh;
vertices = mesh.vertices;
for(int j=0; j<vertices.Length; j++)
vertices[j] = puppets[i].transform.TransformPoint(vertices[j]);
sortedVectors = vertices.OrderBy(v => v.y).ToArray<Vector3>();
Array.Reverse(sortedVectors);
for(int jj=0; jj<10; jj+=3)
{
Ray ray = new Ray(transform.position, sortedVectors[jj]-transform.position);
RaycastHit hit;
int layerMask = 1 << LayerMask.NameToLayer("BackGround");
if(Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{
Debug.DrawRay(transform.position, sortedVectors[jj]-transform.position);
}
}
}
}