2
我的問題是我通過觸摸控制Y軸上的一個對象,但是當我在屏幕上多點觸摸並撤回第一次觸摸時,遊戲對象從第一觸摸位置跳轉到第二觸摸位置。如何阻止Unity中的多點觸控跳轉
我希望即使玩家撤回第一次觸摸,對象的移動仍會像第一次觸摸一樣繼續。
我該如何解決?
我的代碼:
void Update() {
if (die == true)
return;
if(Input.GetMouseButtonUp(0)){
point = transform.position;
click = false;
}
if (Input.GetMouseButton(0)) {
ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
last = ray.GetPoint(1);
if(click==false){
click=true;
first = last;
}
transform.position = new Vector2(0, point.y + last.y - first.y);
}
}
你的代碼甚至沒有多點觸控。要使用多點觸控,您應該使用Input.touches – SteakOverflow
我使用touchCount而不是GetMouseButton(0),但結果不會更改 –