If this question has already been answered please point me in the correct direction. Basically the topic says my problem I used the simple example in unity scripting reference to get the swipe working for left or right but I don’t know how to do the collision detection when my finger hits a certain object, I did see some answers about raycasting which didn’t make sense because I am not using an object todo the swipe I have my swipe script on a camera and even I did do an object it would not have been moving, so just need a little help and direction.
Alright so I am guessing my line for ray is not correct because I have a touchdeltaposition as the vector 3 point from the camera, so I need a little help in trying to see how to detect the finger swiping the item instead of just somewhere on the screen.
After searching I found some code and combined with mine and it works perfectly, the trick to getting it work after you have written code is that you don’t have press hard on the screen just barely touch it and it work 100% of the time. Silly me.
switch (touch.phase)
{
case TouchPhase.Began:
startPos = touch.position;
startTime = Time.time;
break; //here ends the 1st case
case TouchPhase.Moved:
float swipeTime = Time.time - startTime;
float swipeDist = (touch.position - startPos).magnitude;
var ray = Camera.main.ScreenPointToRay(touch.position);
if ((Mathf.Abs(touch.position.x - startPos.x)) < comfortZoneVerticalSwipe (swipeTime < maxSwipeTime) (swipeDist > minSwipeDistance) Mathf.Sign(touch.position.y - startPos.y) > 0 Physics.Raycast(ray, out hit, Mathf.Infinity, mask))
{
if (hit.transform.gameObject.tag == whatever you want)
{
TEXT.TEXT = "Up Collide";
}
}
if ((Mathf.Abs(touch.position.x - startPos.x)) < comfortZoneVerticalSwipe (swipeTime < maxSwipeTime) (swipeDist > minSwipeDistance) Mathf.Sign(touch.position.y - startPos.y) > 0 !Physics.Raycast(ray, out hit, Mathf.Infinity, mask))
{
text.text = "Up";
}
if ((Mathf.Abs(touch.position.x - startPos.x)) < comfortZoneVerticalSwipe (swipeTime < maxSwipeTime) (swipeDist > minSwipeDistance) Mathf.Sign(touch.position.y - startPos.y) < 0 !Physics.Raycast(ray, out hit, Mathf.Infinity, mask))
{
text.text = "Down";
}