- Home /
Get latest touch position?
Hi, Im trying to make a script to scroll up and down and I'm trying to figure out how to get the latest touch position.
For example. when the touch has moved I want the position just before the touch was moved, to check if it should scroll up or down.
How can this be done?
Thanks, Andreas.
Answer by amphoterik · Jul 19, 2013 at 01:13 PM
Create a variable to hold the previous touch position (Vector3). Then, in the update
Compare current position against last position
process as necessary
store current position in last position variable (for next frame)
Touch input info can be found here: http://docs.unity3d.com/Documentation/ScriptReference/Input-touches.html
Answer by IgorAherne · Dec 24, 2016 at 09:42 PM
Use the Touch.fingerId property of touches. Store them in a stack, and check each frame if there is some touch which was not present in the stack before. Of course, you will have to remove touches which are no longer existing from your stack structure.
You can see which one is the most recent by Peek()
Edit: Hm, you can't remove anything from the middle of hte stack. use List structure instead
Your answer
Follow this Question
Related Questions
How to make object follow touch position?Pls Help 0 Answers
vector2 is 0 to 1? 2 Answers
How can I get the current x position of touch in Android? 2 Answers
Creating a GameObject between two 3 Answers
Regarding touch position co-ordinate 1 Answer