"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Need Scripting Support

Hello, my coding is limited and I try to put a prototype together.Iam using Vuforia in Unity for iOS Augmented Visualisation.I have a RING Model that I want to interactive ROTATE on Finger contact. I found this Script. But I need a simple STEP-by-STEP how to use it. Iam willing to pay 100 USD for a working solution. I can even send you my project files. Please help me. Source: http://wiki.unity3d.com/index.php?title=FingerManagerI created this FingerManager.cs script to handle multiple touches, moves, ends and cancels. Just drop it on only one master object and listen to FingerBegin, FingerMove, FingerEnd and FingerCancel messages on all objects you want to be interactive. The target objects need a collider.

 

// Author: <a href="mailto:alex@rozgo.com">alex@rozgo.com</a>
 
// License: enjoy
 
  
 
using UnityEngine;
 
using System.Collections;
 
  
 
public class Finger {
 
   public iPhoneTouch touch;
 
   public bool moved = false;
 
   public ArrayList colliders = new ArrayList();
 
}
 
  
 
public class FingerManager : MonoBehaviour {
 
  
 
   public ArrayList fingers = new ArrayList();
 
  
 
   void Update () {
 
      RaycastHit[] hits;
 
      foreach (iPhoneTouch evt in iPhoneInput.touches) {
 
         if (evt.phase==iPhoneTouchPhase.Began) {
 
            Finger finger = new Finger();
 
            finger.touch = evt;
 
            Ray ray = Camera.main.ScreenPointToRay(evt.position);
 
            hits = Physics.RaycastAll(ray);
 
            foreach (RaycastHit hit in hits) {
 
               finger.colliders.Add(hit.collider);
 
               GameObject to = hit.collider.gameObject;
 
               to.SendMessage("FingerBegin",evt,SendMessageOptions.DontRequireReceiver);
 
            }
 
            fingers.Add(finger);
 
         }
 
         else if (evt.phase==iPhoneTouchPhase.Moved) {
 
            for (int i=0;i<fingers.Count;++i) {
 
               Finger finger = (Finger)fingers[i];
 
               if (finger.touch.fingerId==evt.fingerId) {
 
                  finger.moved = true;
 
                  foreach (Collider collider in finger.colliders) {
 
                     if (collider==null) {continue;}
 
                     GameObject to = collider.gameObject;
 
                     to.SendMessage("FingerMove",evt,SendMessageOptions.DontRequireReceiver);
 
                  }
 
               }
 
            }
 
         }
 
         else if (evt.phase==iPhoneTouchPhase.Ended || evt.phase==iPhoneTouchPhase.Canceled) {
 
            Ray ray = Camera.main.ScreenPointToRay(evt.position);
 
            hits = Physics.RaycastAll(ray);
 
            for (int i=0;i<fingers.Count;) {
 
               Finger finger = (Finger)fingers[i];
 
               if (finger.touch.fingerId==evt.fingerId) {
 
                  foreach (Collider collider in finger.colliders) {
 
                     if (collider==null) {continue;}
 
                     bool canceled = true;
 
                     foreach (RaycastHit hit in hits) {
 
                        if (hit.collider==collider) {
 
                           canceled = false;
 
                           GameObject to = collider.gameObject;
 
                           to.SendMessage("FingerEnd",evt,SendMessageOptions.DontRequireReceiver);
 
                        }
 
                     }
 
                     if (canceled) {
 
                        GameObject to = collider.gameObject;
 
                        to.SendMessage("FingerCancel",evt,SendMessageOptions.DontRequireReceiver);
 
                     }
 
                  }
 
                  fingers[i] = fingers[fingers.Count-1];
 
                  fingers.RemoveAt(fingers.Count-1);
 
               }
 
               else {
 
                  ++i;
 
               }
 
            }
 
         }
 
      }
 
   }
 
}

 

 

Write message handlers like this, on each of your interactive objects.

 
void FingerBegin (iPhoneTouch evt) {
 
}
 
 
 
void FingerMove (iPhoneTouch evt) {
 
}
 
 
 
void FingerEnd (iPhoneTouch evt) {
 
}
 
 
 
void FingerCancel (iPhoneTouch evt) {
 
}

 

 

What I did so far. I create cs file, copy/paste the first code. Then I tried to drop it onto my model but I dont get the second part. The write message handlers and how to include rotation?

 

 

pixelitodesign

Fri, 03/22/2013 - 17:20

iam willing to pay 150 USD instantly via paypal if someone take my project and make this rotation possible. Please its an emergency.