the basic check nearly everyone does for raycasting mouse clicks is something like this:
if (Input.GetMouseButton(1))
{
Plane plane = new Plane(Vector3.up, transform.position);
rayToMouse = Camera.main.ScreenPointToRay(Input.mousePosition);
float dist;
plane.Raycast(rayToMouse, out dist);
Vector3 targetPos = rayToMouse.GetPoint(dist);
if (Physics.Raycast(rayToMouse, out hitTag, layerMask))
{
//if (hitTag.transform.name != "" || hitTag.transform.gameObject.layer == 9)//9 = Ground Layer
//{
MarkerGO.transform.position = new Vector3(targetPos.x, targetPos.y - 1, targetPos.z);
//}
MovePlayerToDestination();
}
}
However in my case I need it to detect height here is a screenshot of the issue. The marker goes under the higher up walkable building even with a layermask…I think the main issue is there is no way to get a layermask for the plane. I can’t figure out a way to get the plane to move up when the mouse is on a higher point.