Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
-1
Question by eradiuslore · Mar 12, 2012 at 01:29 PM · rotationioslerpspin

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 );    
     }
     }
Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Jacob-Aldridge · Mar 12, 2012 at 01:36 PM 1
Share

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

avatar image eradiuslore · Mar 12, 2012 at 03:45 PM 0
Share

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?

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges