Unity3D 物体跟随鼠标移动

xiaoxiao2025-09-16  145

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

转载请注明原文地址: https://www.6miu.com/read-5036429.html

最新回复(0)