Answers for "Project a position onto a plane whose normal isn't at the origin."
http://answers.unity.com/questions/895493/project-a-position-onto-a-plane-whose-normal-isnt.html
The latest answers for the question "Project a position onto a plane whose normal isn't at the origin."Answer by PraetorBlue
http://answers.unity.com/answers/1601608/view.html
Since you are working with *Vectors* and not *Rays*, it is safe to conceptualize all vectors as being "on the origin".
What the projection of the vector on the plane will do is give you the component of the vector which is parallel to the plane. You can then do with this projection whatever you want. Your question is a little unclear with regards to your use case, so it's hard to say much more than that.Thu, 14 Feb 2019 01:55:21 GMTPraetorBlueAnswer by asafsitner
http://answers.unity.com/answers/1315059/view.html
I know it's an old question, but as I ran into the same problem today, I'll answer:
Unity's built-in methods do not have an option to specify the plane's origin, however, it's possible to do so manually and use **[Plane.Raycast][1]** to find the intersection point, for example:
private void ProjectTransformOnPlane(Transform objectToProject, Vector3 planeOrigin, Vector3 planeNormal)
{
Plane projectionPlane = new Plane(planeNormal, planeOrigin);
float distanceToIntersection;
Ray intersectionRay = new Ray(objectToProject.position, objectToProject.forward);
if (projectionPlane.Raycast(intersectionRay, out distanceToIntersection))
{
objectToProject.position = objectToProject.position + objectToProject.forward * distanceToIntersection;
}
}
This principle can be modified and applied to different scenarios, but in each of them, we must have the origin and direction of the vector we'd like to project onto the plane.
In this case, I used the Transform's forward to find its direction, but any other vector can be used.
[1]: https://docs.unity3d.com/ScriptReference/Plane.Raycast.htmlSat, 18 Feb 2017 04:42:22 GMTasafsitner