- Home /
Spinning Sphere/Globe IOS
hey im writing a spinning globe script for an IOS application that as you can guess spins a sphere around based on touch input. my problem is that it works really well in debug, but on the pad not so much.
in Debug i have nice smooth movement and you can click on a position on the globe and drag it in the Y axis making it spin, on the pad however it lerps the rotation a significant amount when i touch the globe, where as it should stay perfectly still till i move my finger like in debug.
any thoughts anyone has on whats wrong with my code is very much appreciated
 using UnityEngine;
 using System;
 using System.Collections;
 
 public class dragScript : MonoBehaviour {
     
     private Vector3 m_Speed;
     private Vector3 m_AvgSpeed;
     private bool m_Dragging = false;
     
     public float m_ModSpeed =1;
     public float m_ModRotationSpeed =3;
     
     public void OnMouseDown () {
         m_Dragging = true;
     }
     
     public void Update () {
         if (Input.GetMouseButton(0) && m_Dragging) {
             Debug.Log("HIT new drag");
             m_Speed = new Vector3(-Input.GetAxis ("Mouse X"), /*Input.GetAxis("Mouse Y")*/0, 0);
             m_AvgSpeed = Vector3.Lerp(m_AvgSpeed,m_Speed,Time.deltaTime * 5);
         } else {
             if (m_Dragging) {
                 Debug.Log("HIT decrease speed");
                 m_Speed = m_AvgSpeed;
                 m_Dragging = false;
             }
             Debug.Log("HIT Lerp");
             float i = Time.deltaTime * m_ModSpeed;
             m_Speed = Vector3.Lerp( m_Speed, Vector3.zero, i);
         }
         Debug.Log("HIT rotate");
         transform.Rotate( Camera.main.transform.up * m_Speed.x * m_ModRotationSpeed, Space.World );    
     }
     }
You should look into using GetTouch() functions when dealing with mobile devices. The Get$$anonymous$$ouseButton() function is really just for a mouse.
http://unity3d.com/support/documentation/ScriptReference/Input.GetTouch.html
yeah i should note that i use the 3rd example on that page to find objects you have touched with a raycast then sending a message to the object to activate On$$anonymous$$ouseDown. e.g. obj.Send$$anonymous$$essage("On$$anonymous$$ouseDown");
do you think having it set up like that is going to be causing the problem?
Your answer
 
 
             Follow this Question
Related Questions
iOS - Smooth auto-rotation of orientation 1 Answer
Simple rotation script. (loop) 3 Answers
Use Lerp to rotate object 2 Answers
Constant rotation? 2 Answers
Unit rotation fails consistently on all slerp rotations after the first? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                