- Home /
How can I get the current x position of touch in Android?
Hello, how can I get the current X position of the users touch in android if the screen is touched? For example when I touch the screen there will be printed the X position in the Console? (using the Unity Remote)
Is that possible?
Thanks, Andreas :-)
Answer by Graham-Dunnett · Apr 22, 2013 at 08:32 PM
You're joking right? The example at http://docs.unity3d.com/Documentation/ScriptReference/Input.GetTouch.html shows how you can access the touch events. And see http://docs.unity3d.com/Documentation/ScriptReference/Touch-position.html for the coordinates of the touch on the screen.
No, i'm not :-) I'am completely new to Android, and I couldn't find any help on Google. Thanks for the links :-)
NP. The docs are included in the editor installer, so no need to use Google.
Answer by Loren-Logic · Apr 22, 2019 at 03:53 PM
@Graham-Dunnett, I resent your sarcasm. Read those examples yourself, and tell me where they say how the screen coordinates are to be interpreted at all the possible orientations of the device's screen, relative to Andreas' Unity game? Do they change when the device orientation changes, or does Andreas have to compensate-- e.g., Input.GetTouch.position.y becomes -.x in landscape left orientation? Those examples don't address that issue. So,, when you scoff at his question, your presumption that you know what he is thinking is really, really inappropriate. You gave him good links, but you've no reason to ridicule his perfectly reasonable question because you have not a clue why he is asking it. The documentation is incomplete and imperfect; therefore, your presumption that he hasn't read them or comprehended them is almost certainly wrong.
Your answer
Follow this Question
Related Questions
Detect if finger lifted off screen 1 Answer
unity 5.2 Input.GetTouch(0).position incorrect? 3 Answers
How to get TouchPosition ?? 1 Answer
Android - touch a 3d object and something happens to it 1 Answer
iPhone Droid Input.GetTouch(i).position 4 Answers