• 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
Question by jaffer · Apr 19, 2014 at 02:43 AM · movementjitterstutterjitteringjittery

Movement jitter every few seconds

Hi All,

Project Link: https://www.dropbox.com/sh/7xqzoz6pbpke7ya/U2pNHVqzRX

I am trying to move basic box objects from right part of the screen towards left with Lerp. I am testing it on my android (Galaxy S4) It moves smooth but every few seconds screen jitters or stutter w$$anonymous$$ch is very annoying.I have searched everywhere but no solid solution to t$$anonymous$$s. With Vsync on its even worst.

I have also tried t$$anonymous$$s with object pooling, still same jitter. PLEASE HELPPPPP

I have tried the following;

  • Update

  • FixedUpdate

  • LateUpdate

And for movement;

  • Translate

  • Lerp

  • Move forward

not$$anonymous$$ng seems to be working and any help would be appreciated.


using UnityEngine; using System.Collections;

public class moveScript : MonoBehaviour {

 private Vector3 newPosition;
 public float speed = 10.0f;
 private int randomNum;

 void Update () {

     randomNum = Random.Range (0, 2);
     movers ();
     resetPosition ();

 
 }

 private void movers(){
     Vector3 posB = new Vector3 (transform.position.x - 5 * Time.fixedDeltaTime , transform.position.y, transform.position.z);
     newPosition = posB;
     transform.position = Vector3.Lerp (transform.position, newPosition, Time.smoothDeltaTime *  speed);
 }

 private void resetPosition ()
 {
     if (transform.position.x <= -4) 
     {
         if(randomNum > 0)
         {
             transform.position = new Vector3(5.0f,-0.2f,0.0f);
         }
         else
         {
             transform.position = new Vector3(5.0f,0.2f,0.0f);
         }
     }

 }

}

Comment
robertbu

People who like this

1 Show 8
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 mostlytigerproof · Apr 19, 2014 at 03:41 AM 0
Share

Uh, why are you using Lerp? If you want to travel along the X axis at a constant rate, you could just add to position.x.

Secondly, use Time.deltaTime or smoothDeltaTime if you're getting called from Update. Only use Time.fixedDeltaTime if you're getting called from FixedUpdate.

Thirdly, beware of "Power saving mode" on Samsung Galaxies. This will cap the framerate to 40fps and you'll never be properly vsynced with that on.

avatar image jaffer · Apr 19, 2014 at 04:05 PM 0
Share

hey thanks for the reply, so i have tried moving along the x axis with;

 Vector3 pos = transform.position;
 pos.x += 10 * Time.smoothDeltaTime;
 transform.position = pos;

and my Galaxy S4 "Power saving mode" is off, also tried with Update, FixedUpdate, LateUpdate. And when the Vsync is on it jitters even worst.

avatar image drudiverse · Apr 19, 2014 at 04:09 PM 0
Share

is it a frame rate problem or a processing problem? your code works fine on PC?

avatar image jaffer · Apr 19, 2014 at 04:17 PM 0
Share

on PC its not as bad as it is on the Android. Frame rate is running at 60 but every few seconds it drops to 58-59.

what is GFX.WaitForPresent

Image for Profiler: https://www.dropbox.com/s/20pps15gbgrqock/Untitled-4.jpg

avatar image mostlytigerproof · Apr 19, 2014 at 11:40 PM 0
Share

Present() is a direct3d call that swaps framebuffers. I guess WaitForPresent is the Unity equivalent where it waits out the rest of the Vsync interval.

Your profiler trace looks absolutely fine to me. No allocs and the spikes from 0.1ms to 1ms are probably just the OS scheduler taking a time slice here and there.

What kind of jittering are you seeing? I see a very slight shimmer from where the positions aren't rounded on to pixel boundaries, but it sounds like you're seeing short freezes. On a Galaxy S3 I get a couple of ~0.2 second stalls after start up, which is business as usual on Android. Otherwise it runs smoothly.

I guess you could try watching the OS logging via adb logcat to see what happens during the freeze.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by nikescar · Apr 21, 2014 at 12:45 AM

Try turning development build off. Profiling can help track down problem scripts and stuff but, it has a performance overhead since it sends data frequently. Also, in the profiler, click on the spikes and see what is causing them. My guess is the skipping will disappear when the profiler is no longer running.

Comment

People who like this

0 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 jaffer · Apr 22, 2014 at 03:28 PM 0
Share

development build is off and on my pc i dont see the jitter/hiccups anymore..but its major on android.i have tried different phones galaxy S4 and S3. same on both.

avatar image nikescar · Apr 22, 2014 at 08:06 PM 0
Share

Here is your project with my modifications

Look at my changes to the movers method. You didn't need to multiply posB by the Time.fixedDeltaTime because you are using lerp below that. Also, you want to match the deltaTime with the method you are using it in (if in Update use deltaTime, if in FIxedUpdate use fixedDeltaTime). I made this run in Update but, really, you want to move physics objects in FIxedUpdate always.

That said, I made the assumption that these were to be physics objects.

I also added a Rigidbody2D to each of your boxes (with isKinematic checked) because, if I remember correctly, it is less of a hit on performance when moving colliders.

This runs perfectly smooth on my Nexus 7.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

23 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 avatar image avatar image

Related Questions

Jittery camera motion in GearVR when moving camera - nothing seems to work. 2 Answers

micro Jittering, stuttering... bug of unity? 2 Answers

Gravity controller is buggy 0 Answers

Jittering transform translate with static camera 0 Answers

Jittery FPS Camera when moving 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