- Home /
Question by
Gravitox · May 24, 2014 at 09:39 PM ·
raylinelayerintersection
Intersection between line (ray) and xz-layer at specific high
Hello
How do I calculate the point of intersection of a line (ray) and the xz-layer witch is at a specific high?
Example: I create a ray with ScreenPointToRay from the camera looking down at 90° with a high of 10. With ray.direction I get it's direction but how do I calculate when this ray intersects the xz-layer at high 0 without using a collider?
Sorry for my english...
Gravitox
Comment
Best Answer
Answer by robertbu · May 24, 2014 at 09:45 PM
You can use Unity's mathematical plane class. See the reference page for Plane.Raycast() for an example. For your use the 'groundPlane' variable would be initialized as:
groundPlane = new Plane(Vector3.up, Vector3.zero);