方法一(直接获取 Input.mousePositon):
将Camera设置为正交模式。
target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
target.y = ChessPiece.transform.position.y;
ChessPiece.transform.position = target;
注:将其中一个坐标修改为物体自带的。因为转换出来的坐标中,有一维是错误的,具体是哪一维,看具体情况。
方法二(碰撞射线):
将Camera设置为透视模式。
https://blog.csdn.net/xufeng0991/article/details/52254502 (转)