Exemplo n.º 1
0
    public static Vector2Int GetHoveredTile()
    {
        var camera = Camera.main;
        var ray    = camera.ScreenPointToRay(Input.mousePosition);
        var plane  = new Plane(Vector3.back, Vector3.zero);

        if (plane.Raycast(ray, out float dist))
        {
            var point3D = ray.GetPoint(dist);
            return(BoardUtil.Position3DToTileCoord(point3D));
        }
        else
        {
            return(new Vector2Int(99999, 99999));
        }
    }