- Home /
 
 
               Question by 
               shygeek · Mar 14, 2014 at 07:37 PM · 
                gameobjectraycastswipe  
              
 
              Swipe individual gameobject in a scene
Hello ! I've a scene in which I need to swipe on individual gameobjects. I think I'll have to use raycast function for this. But I'm really new to coding. Can someone help ?
My present swipe code for up/down swipe(detects swipe on the whole screen)
var finid:int=-1;
var uptest:boolean=true;
var downtest:boolean=true;
var StartPos:Vector2;
var dis:float=20.0;
var top : GameObject;
var front : GameObject;
function Update ()
{
for(var touch:Touch in Input.touches)
{
var pos = touch.position;
         if (touch.phase == TouchPhase.Began && finid == -1)
         {
             finid = touch.fingerId;
             StartPos = pos;
             
         }
         else if (touch.fingerId == finid)
         {
             var delta = pos - StartPos;
             if (touch.phase == TouchPhase.Moved && delta.magnitude > dis)
             {
                 finid = -1;
                 if (Mathf.Abs(delta.x) > Mathf.Abs(delta.y))
                 {
                 //
                 }
                 else
                 {
                     if (uptest && delta.y > 0)
                     {
                     Debug.Log("up");
                     top.SetActive(true);
                      
                     }
                        
                     else if (downtest && delta.y < 0)
                         {
                         front.SetActive(true);
                   
                         }
                 }
                
             }
             else if (touch.phase == TouchPhase.Canceled || touch.phase == TouchPhase.Ended)
                 finid = -1;
         }
     }
 
               }
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Swipe individual gameobjects in a scene 0 Answers
Creating a teleportation gun 1 Answer
Raycast when swipe or touchphase move 0 Answers
Raycast object tag check? 3 Answers
Raycast starts ignoring gameobject after a few seconds 0 Answers