MousePos To Transform

I making a plat-former and need to convert the mouse to a position, however its a platformer so Z must always = 0. Before you ask whether I’ve searched or looked at the scripting reference… YES I have! :slight_smile:

If you want to pick a point on a “Plane” in 3D space using the mouse, you can just do that. Create a “Plane” with the right position (SetNormalAndPosition) facing e.g. towards the camera, then create a ray from the mouse position and do a raycast against the plane. Here some snippets without context:

_ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (_plane.Raycast(_ray, out distance))
{
                _hitPoint = _ray.GetPoint(distance);