- Home /
Scripting to receive a touch over a specific area
I was wondering if anyone had any ideas on how to script (specifically C#) so that a swipe on a tablet across a preset area activates an if statement or something similar? What I'm trying to achieve is that when the player swipes a certain line that will be shown, it activates a certain animation from frame 0 to say 5. Another swipe would then progress the animation forward another 5 frames or so. I can script the animations and the whole progression thing pretty easily to activate on a single touch or a click, but the whole swipe thing is giving me problems. I've tried looking it up everywhere but haven't found much luck. Is there a way to make GetTouch work on a list of points maybe, or would raycasting be a better way to go? Or something else entirely? Thanks for any help!
If you are having trouble with implementing the swipe, google "unity3d swipe," and you will find many hits. As for a specific area or "line," you would create a rect in screen coordinates that contained the line. If the swipe started in the rect, then you could move forward in the animation. How you map your "line" into screen coordinates will depend on how you display the line. The mapping will be different for all the different way you can display a line: GUI, GUIText, plane game object, 3D Text...
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Problems with Raycast 0 Answers
[Unity Editor] Emulate Touch Input - Still Asking 12/10 1 Answer
Custom Collision Detection 4 Answers
physics2d.raycastall help please 1 Answer