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 Gera1997 · May 20, 2015 at 04:03 PM · mobiletouchoptimizationlagunity remote

Touch Input only working on Unity Remote

Well First post ever, here we go, I apologize for any bad english, not a native speaker. When I test my app on Unity Remote it works just fine, but when I install it on my phone, the touch, only the touch, is very laggy, like it has some sort of delay. The animations, the rendering, all other gameobjects seem to work just fine.

I optimized as much as I could, meshes, shadows off, shared materials, script optimization. I even switched the quality settings form "Fantastic" to "Fastest". And altought I did get an improvement the touch is still a bit laggy.

My FPS is around 500 - 700fps most of the time, altough it goes down to around 200fps in some parts of the courutinnes. (Around once in every minute). Insane drop I know, but as far as I know 200fps is still a very good number. Altough I am developing on a PC with a very good processor and I am testing on a very poor android device so... well you know.

Here is the script I use for my touch input, it controls a ball by swipping up,down,left and right:

private void Awake() { // Set up the reference. ball = GetComponent(); }

     private void Update()
     {
         if (Input.touchCount > 0)     
         {
         h = 0;
          v = 0; // stops character
         Touch touch = Input.touches[0];
         switch (touch.phase) 
             {
         case TouchPhase.Began:
             startPos = touch.position;
             break;    
         case TouchPhase.Ended:
                 float swipeDistVertical = Mathf.Abs(touch.position.y - startPos.y); // distance touch moved in Y axis
                 float swipeDistHorizontal = Mathf.Abs(touch.position.x - startPos.x); // distance touch moved in X axis
                 if (swipeDistVertical > swipeDistHorizontal) // compare Y movement and X movement to see where player was attempting to swipe
                 {
                     // player attempted to swipe vertically
                     v = Mathf.Sign(touch.position.y - startPos.y); // if -1 moved down, if 1 moved up;                     
                 }
                 else
                 {
                     // player attempted to swipe horizontally
                     h = Mathf.Sign(touch.position.x - startPos.x); // if 1 moved right, if -1 moved left
                 }
             break;
             }
         }
     move = (v*Vector3.forward + h*Vector3.right).normalized;
     }


     private void FixedUpdate()
     {
         // Call the Move function of the ball controller
         ball.Move(move);
     }
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 hexagonius · May 20, 2015 at 05:13 PM 0
Share

How do you define "laggy"? What's the outcome of the lag? Since your touch is only defining a Vector3's value, I don't think it's the actual problem.

avatar image Gera1997 · May 20, 2015 at 05:35 PM 0
Share

Hi hexagonius thanks for responding, what I was trying to mean is that the touch takes time to respond, when I swipe up for example, the ball should inmeaditly move up, however it takes about half a second for the ball to do so.

Perhaps this script is not the problem, maybe I need to go further in the game optimization?

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How do i get rid of touch lag between touch ending on device and action in game? Or is it possible, on Unity Remote 4 using Nexus 7 2012 with if (Input.touchCount > 0) for touch input? 1 Answer

Alternative to SendMessage()? / Mobile Optimization 1 Answer

Unity3.4 Mobile Terrain Lag 1 Answer

Touch screen input - Optimisation 1 Answer

The joystick isnt working in Unity remote 5 3 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