Please Help me with multitouch
I try touch left and forward, but it don't work. why?(
void Update () {
test = Input.touchCount;
string operations = "0";
foreach (Touch touch in Input.touches) {
//if(touch.phase == TouchPhase.Began)
Ray touchRay = Camera.main.ScreenPointToRay(touch.position);
RaycastHit[] hits = Physics.RaycastAll (touchRay);
foreach (RaycastHit hit in hits) {
operations += hit.transform.gameObject.name + " ";
}
pushed = "";
if (operations.Contains("go") && operations.Contains ("left")) {
pushed += "left";
player.transform.Rotate (-Vector3.up * turnSpeed * Time.deltaTime);
pushed += "go";
player.transform.Translate (Vector3.forward * speed * Time.deltaTime);
}else if (operations.Contains("go") && operations.Contains ("right")) {
pushed += "right";
player.transform.Rotate (Vector3.up * turnSpeed * Time.deltaTime);
pushed += "go";
player.transform.Translate (Vector3.forward * speed * Time.deltaTime);
}else if (operations.Contains ("left")) {
pushed += "left";
player.transform.Rotate (-Vector3.up * turnSpeed * Time.deltaTime);
}else if (operations.Contains ("right")) {
pushed += "right";
player.transform.Rotate (Vector3.up * turnSpeed * Time.deltaTime);;
}else if (operations.Contains ("stop")) {
pushed += "stop";
player.transform.Translate (-Vector3.forward * speed * Time.deltaTime);
}else if (operations.Contains("go")) {
pushed += "go";
player.transform.Translate (Vector3.forward * speed * Time.deltaTime);
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Move GameObject to touchpoint with one touch 2 Answers
Dragging an object stops when second touch is applied to mobile screen 0 Answers
Handle custom touches (any way to SET input.Touches from another touch array?) 0 Answers
Rotate object along y axis with touch input continously 0 Answers
TouchScript Library - Continually (by frame or change of position) get touch position 0 Answers