1 回答

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超6個(gè)贊
您需要翻轉(zhuǎn)它,以便使用 Input.mousePosition.y 作為 z 軸,使用 startPos 作為 y 軸。這應(yīng)該有效:
public class MovementController : MonoBehaviour
{
private const float planeY = 0f;
Plane plane = new Plane(Vector3.up, Vector3.up * planeY); // ground plane
void OnMouseDrag()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
float distance; // the distance from the ray origin to the ray intersection of the plane
if(plane.Raycast(ray, out distance))
{
transform.position = ray.GetPoint(distance); // distance along the ray
}
}
}
- 1 回答
- 0 關(guān)注
- 118 瀏覽
添加回答
舉報(bào)