but I’m wondering if there’s a more efficient way of doing it without a raycast or a plane if I can specify Y as a constant? This may be the best solution out there, but I’m curious if anyone has a better one before I call it.
A slightly cheaper raycast would be against a Plane(assuming that currently floor is a collider).
Example:
Plane plane = new Plane(Vector3.up,0);
float dist;
Ray ray = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
if (plane.Raycast(ray, out dist))
{
Vector3 point = ray.GetPoint(dist);
}
but if you are using a downward-pointing camera, as it sounds, you will probably need to swap y and z coordinates… since “z” is the distance from the camera, i.e.:
var myTempPoint : Vector3 = Camera.main.ScreenToWorldPoint(Input.mousePosition);
var myWorldPoint : Vector3 = new Vector3(myTempPoint.x,myYConstant,myTempPoint.y);