- Home /
check user touching a particular position or not
i am making a game,where user always need to start drag his finger from start position and give error if not. am new with touch in unity so am not aware with it. the user should start from position marked start as shown in figure.
Answer by robertbu · Oct 04, 2014 at 02:44 PM
There are multiple technical issues here, and in the absence of your code or more information, it is unclear what part(s) of this problem you are struggling with. As @GrahamDunnett mentioned, see Input.GetTouch() if you are trying to figure out the touch aspects. Rather than use the code in the manual, I suggest you write your code so that Input.touchCount must be 1 (once started dragging). This will prevent cheating with multiple fingers.
Here is a simplistic way to detect the walls (using a single touch position)
Display the maze in world space using a Quad
Make the texture used on the material read/write enabled
Raycast against the Quad using the Input.GetTouch(0).position
Use the RaycastHit.textureCoord and Texture2D.GetPixel() to get the pixel
Use the color of the pixel to tell what you are touching. Use color distance rather than a direct color comparison.
Your answer
Follow this Question
Related Questions
Moving object with touch input and detecting collision 1 Answer
Lerp not working 1 Answer
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