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
0
Question by tuhinbhatt · Feb 11, 2013 at 03:41 PM · iosinputtouchtransform.positioninput.touch

Drag an object to touch position(Problem)

I am using the below code to move the object to touch postion. I am developing for ios. Below is the code

 using UnityEngine;
 using System.Collections;
 
 public class dragtheobjectontouch : MonoBehaviour {
 
     public GUIText debugtext;
     public GameObject dragobject;
     public Vector2 realworldposition;
     
     void Awake()
     {
     Application.targetFrameRate=60;
     }
     
     void Update () {
     if(Input.touchCount>0)
         {
         foreach(Touch touch in Input.touches)
             {
             if(touch.phase==TouchPhase.Moved)
                 {
                 debugtext.text=touch.position.ToString();
                 realworldposition=Camera.main.ScreenToWorldPoint(touch.position);
                 dragobject.transform.position=new Vector3(realworldposition.x,realworldposition.y,dragobject.transform.position.z);
                 }
             }
         }
     }
 }


The Above code works perfectly but the problem is when i start moving the finger on ipad very fast the object lags behind the finger as if it is following it. Ofcourse it comes to the perfect position of touch when i stop moving the finger on the screen, but it really lags when the finger moves very quickly on the screen.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by robertbu · Feb 11, 2013 at 08:36 PM

I found the question interesting, so I poked around a bit. If you Google some combination of "iOS/iPhone/iPad Touch/Input Lag/Lagging" you will find a bunch of hits not just for Unity but for iOS apps in general. This seems to be a general problem with touch devices (iOS and Android). The lag seems to be a hardware issue with the device and not something that can be solved by the apps.

The fact that your object eventually catches up to your finger is a strong indication this is a hardware issue. I did read in one place where a developer felt he had mitigated the issue somewhat by increasing the frame rate. There are downsides to increasing the FPS, but if you want, apparently it can be set like this:

  Application.targetFrameRate = 60;

I don't have time to run the test at the moment, so if you test it, please post your results back to the list.

Here is one page that talks about hardware lag:

Lag: The Bane Of Touch Screens

Comment
Add comment · Show 2 · Share
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 tuhinbhatt · Feb 12, 2013 at 09:13 AM 0
Share

I already thought of increasing the framerate, so as you can see in the above code i have already increased the framerate to 60 before posting the question. Just check the awake function in my above posted code. But the Problem was not solved by increasing the framerate to 60. I did read the article from the link you posted. You might be right, it might be due to hardware lag.

avatar image tuhinbhatt · Feb 12, 2013 at 09:14 AM 0
Share

If you do find out any solution, do post it here as that would be really helpfull to me and lot of others. And also one more thing the person who wrote this article is right about it. As even in the home screen of ipad4 when i move the icon with touch very quickly it lags behind the finger. So this is definitely the hardware issue and i don't think we can do anything about this. Thanks for your help and especially the link to the article.

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Detect a tap versus standing touch on iPhone? 3 Answers

Touch input reporting 0 delta for first several Updates on iOS, 2 Answers

How to fix this problem? ios touch screen? 1 Answer

Way to detect and get last/latest TOUCH 5 Answers

Touch joystick tutorials ? 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