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 Kcrik59 · Mar 15, 2015 at 05:06 PM · android2dmovementissuelinear

Linear laggy/stuttery movement

Hello,

I have been going through the forum to check if some one had an answer to my problem. I am implementing a small 2d game. When some one touch the screen, the main object moving to that position in a linear way.

I used DOTween and iTween to do it at the beginning, but I noticed a jump while moving when using either of them. Basically it looks like the position is being updated more times than the GPU can take it to show it smoothly. (and I'm pretty sure it's the issue considering what I have read on the forum ).

My issue is now I have tried attaching a rigidbody2d to my object to use Velocity and so the position updates aren't up to me, but it's even worse. My update algo is :

 // Calculate how much to translate of
 
 m_movement.x = m_direction.x * Time.smoothDeltaTime * SPEED;
 m_movement.y = m_direction.y * Time.smoothDeltaTime * SPEED;
 
 // Calculate the next position
 m_nextPosition.x = transform.position.x + m_movement.x;
 m_nextPosition.y = transform.position.y + m_movement.y;
 
 // Calculate the new distance between the point touched on screen and the object
 float currentDistance = Vector2.Distance (new Vector2 (m_nextPosition.x, m_nextPosition.y), m_targetPosition);
 
 // we have reached the target position or the next position is going to be slightly further away
 // Then just stop updating the position and set the new position as the target position
 if (currentDistance == 0 || currentDistance > m_prevDistance)
 {
     m_state = STATE.IDLE;
     m_prevDistance = -1;
     transform.position = m_targetPosition;
     m_prevDistance = 0;
 }
 // Otherwise move the object and update the distance between target position and current position
 else
 {
     transform.Translate(m_movement);
     m_prevDistance = currentDistance;
 }

On MAC, it obviously doesn't go wrong, but on iPhone4, Samsung mini-s4 and HTC M8, I have some stuttery/jump/laggy movement...Any idea how to sort that out ?

I tried FixedUpdate, Time.deltaTime, Time.fixedDelta. Using rigidbody2d as I said, clamping the Time, to make sure it's not greater than 0.03 or making sure the range is between 0.02 and 0.04 , but none stops the laggy altogether.

Any idea guys ?

I can add a video if needed.

Thanks

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
0

Answer by Ulydev · Mar 15, 2015 at 09:33 PM

Have you tried LateUpdate ?

EDIT : Just realised you were using a Rigidbody. You shouldn't update its transform, but rather move it using setVelocity.

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 Kcrik59 · Mar 15, 2015 at 09:57 PM 0
Share

Just tried. It still does it :-(

I read other threads where it says it's really hard to do a 2d game with smooth linear movement...but games on nes and snes had smooth linear movement, so no way it's not doable !

avatar image Ulydev · Mar 16, 2015 at 05:50 AM 0
Share

Have you tried replicating the issue in a 3D space ? And see how it does ?

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

21 People are following this question.

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

Related Questions

Make an object that moves relative to the touch more natural 0 Answers

I Need Help With Mobile Touch Movement. 0 Answers

Android OnMouseDown character movement 2 Answers

Move horizontally on touch 0 Answers

Android 2d movement/waypoint script issues 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