- Home /
Gear VR taps and swipes
I have a script moving the camera horizontally along an iTween path
It works in Unity with mouse drags & iOs
my input > Fire 1 input >MouseX & Horizontal are set correctly
here is the script:
void Update () {
if (Input.touchCount > 0) {
Touch touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved) {
percentage -= touch.deltaPosition.x * speed / Screen.height;
percentage = Mathf.Clamp01(percentage);
iTween.PutOnPath(gameObject,movePath,percentage);
iTween.PutOnPath(lookTarget,lookPath,percentage);
// transform.LookAt(iTween.PointOnPath(lookPath,percentage));
}
}
if(Input.GetKey(KeyCode.UpArrow))
{
percentage -= speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.DownArrow))
{
percentage += speed * Time.deltaTime;
}
percentage = Mathf.Clamp01(percentage);
iTween.PutOnPath(gameObject,movePath,percentage);
iTween.PutOnPath(lookTarget,lookPath,percentage);
transform.LookAt(iTween.PointOnPath(lookPath,percentage));
if (Input.GetMouseButtonDown(0)) //if left mouse button is pressed
{
initCursorPos = Input.mousePosition.x;
initPercentage = percentage;
}
if (!Input.GetMouseButton(0)) //if left mouse button not pressed
{
percentage += speed * Time.deltaTime;
}
else //if not pressed
{
Debug.Log("Left mouse button not pressed");
if (Input.mousePosition.x - initCursorPos > 5) //drag to the right
{
Debug.Log("Drag to the right");
percentage = initPercentage - (Input.mousePosition.x - initCursorPos) * dragSpeed * 0.1f;
}
else
if (Input.mousePosition.x - initCursorPos < -5) //drag to the left
{
Debug.Log("Drag to the left");
percentage = initPercentage - (Input.mousePosition.x - initCursorPos) * dragSpeed * 0.1f;
}
else //stand still
{
Debug.Log("Stand still");
}
}
}
nothing in Gear.
Even the automatic movement on the camera doesn't work
Any ideas ? Thanks ~be
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612113011im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Unity won't accept Android SDK Location 1 Answer
Having trouble building app for Vive Focus Plus 0 Answers
Artifacts while using google vr sdk 1 Answer
xml/network_sec_config not found 0 Answers