【发布时间】:2015-04-22 21:55:30
【问题描述】:
我的问题是我通过触摸控制Y轴上的对象,但是当我在屏幕上进行多点触摸并撤回第一次触摸时,游戏对象从第一次触摸位置跳转到第二次触摸位置。
我希望即使玩家退出第一次触摸,对象的运动也会像第一次触摸一样继续。
我该如何解决?
我的代码:
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
-
我使用 touchCount 而不是 GetMouseButton(0) 但结果没有改变
标签: c# unity3d multi-touch gameobject