Raycast is returning false

It working but after some time it is not working. It started returning a false value.

`void update()
{ obj = new Plane(Camera.main.transform.forward * -1, this.transform.position);
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float raydistance;
if (obj.Raycast(ray, out raydistance))
{
startPos = ray.GetPoint(raydistance);
// Debug.Log(ray.GetPoint(raydistance));

        }

}`

It’s not clear where this script is attached to and if it’s completely inside the viewing frustum of your camera. You create the mathematical plane at the location of the object this script is attached to and you used the inverse of the camera forward axis as normal. So your infinite plane will always be perpendicular to your screen, However if for example you move or rotate the camera, the “origin” of the plane might get behind the camera so your plane is outside of the view frustum.

You haven’t given enough information to answer this question. All we know about your project is what we see here in your question. The tutorial you’ve linked seems to do something quite different. So can you ensure that the object this script is attached to as well as the camera doesn’t move or rotate? If not, that’s your problem. Since you haven’t said what you want to achieve we can’t help you any further at this point. You may want to edit your question and add more details if you need more help.