- Home /
Unity Touch input not working when i built to android
I am using unity 2020.3.ff1 and i'm working on a mobile game. I have inplemented a way to move my player by dragging(code below). When I test this using unity remote 5, it works just fine. However when i try to build it i get an error. I can still press buttons but dragging doesn't work.(HiTouch touch pointer move a lot. The moving distance of X is:39.292603, limit is:60The moving distance of Y is:72.54346, limit is:60)
If someone knows more, please help.
if (Input.touchCount > 0) { Touch touch = Input.GetTouch(0); Vector2 touchPos = Camera.main.ScreenToWorldPoint(touch.position); switch (touch.phase) { case TouchPhase.Began: deltaX = touchPos.x - transform.position.x; deltaY = touchPos.y - transform.position.y; break;
case TouchPhase.Moved:
rb.MovePosition(new Vector2(touchPos.x - deltaX, touchPos.y - deltaY));
break;
case TouchPhase.Ended:
rb.velocity = Vector2.zero;
break;
}
}
Your answer
Follow this Question
Related Questions
Input.GetTouch never getting TouchPhase.Ended on Android 0 Answers
Zenfone 2 and Unity Native VR 2 Answers
Compiling Android game doesn't work out 0 Answers
"CommandInvokationFailure: Gradle build failed" when building to Android 1 Answer
How can I debug an Android game that crashes at launch (after Unity logo)? 1 Answer