Log in or register to post comments

Need Scripting Support

March 22, 2013 - 9:35am #1

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=FingerManager

I 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?

 

 

Need Scripting Support

March 25, 2013 - 9:20am #6

ok

Need Scripting Support

March 25, 2013 - 9:17am #5

Hi, Probably don't need the project file, and I don't have Unity 4 yet anyways.

I'll PM you the details on how to do this.

Need Scripting Support

March 25, 2013 - 9:09am #4

No, nobody could help me yet. Are you interested? I can email you  link to my project file asap

Need Scripting Support

March 25, 2013 - 8:58am #3

Hi, anyone collected the bounty on this?  I might be able to help.

Need Scripting Support

March 22, 2013 - 10:20am #2

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

Log in or register to post comments