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?
Need Scripting Support
iam willing to pay 150 USD instantly via paypal if someone take my project and make this rotation possible. Please its an emergency.
Need Scripting Support
Hi, anyone collected the bounty on this? I might be able to help.
Need Scripting Support
No, nobody could help me yet. Are you interested? I can email you link to my project file asap
Need Scripting Support
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
ok