方法一(直接獲取 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 (轉)