I have two perpendicular planes in xz and yz like this
I want to find the projection of the vertices of plane 2 on plane 1 using raycasting.The rays are hitting the plane but the log is showing zeros. why?
using UnityEngine;
using System.Collections.Generic;
//[ExecuteInEditMode()]
public class PlaneManipulation : MonoBehaviour {
Ray ray;
RaycastHit hit;
Mesh mesh;
private Vector3[] vertices;
public float rayLength;
public LayerMask planeLayer;
void ChangeMesh() {
mesh = GetComponent<MeshFilter>().sharedMesh;
vertices = mesh.vertices;
//using only the first row of the vertices from the plane
for (int i = 0; i < 11; i++)
{
Vector3 vert = transform.TransformPoint(vertices[i]);
Physics.Linecast(vert, Vector3.up, out hit,planeLayer);
Debug.DrawRay(vert, Vector3.up);
Debug.Log("hitPoint = " + hit.point);
//vert.y = hit.point.y;
//vertices[i].y = hit.point.y;
//vertices[i] = transform.InverseTransformPoint(vert);
}
mesh.vertices = vertices;
mesh.RecalculateNormals();
mesh.RecalculateBounds();
}
void Update() {
ChangeMesh();
}
}