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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by theProtagony · Aug 28, 2014 at 06:05 AM · androidmovement scriptstutter

Why is this stuttering so much?

I'm attaching an extremely simple movement script. The game is a white cube moving across a black screen and repeats. No spawning, no sounds, no special effects and no gimmicks with the camera.

There is just one camera and one object in the scene.

I have looked around for answers to the stuttering question and people are sending basic answers like using TimeDelta / some other method. The script in this project contains both known methods for linear movement:

Update() with TimeDelta and RigigBody2D velocity. Easily switchable in code, same results.

Can somebody please point out what the solution might be? If not, I'd like this project to kick off a serious discussion of rampant stuttering - especially on Android.

Using this script on a simple 64x64 object, landscape mode deployment


 using UnityEngine;
 using System.Collections;
 
 public class Movement : MonoBehaviour {
 
     private Transform objTransform;
     private Vector3 pos;
     private Vector2 velocity = new Vector2(-6.0f, 0.0f);
 
     private int movementMethod = 0;
 
     // Use this for initialization
     void Start () {
         objTransform = gameObject.transform;
         pos = objTransform.localPosition;
     }
     
     // Update is called once per frame
     void Update () {
 
         if(movementMethod == 1)
         {
 
             pos.x -= Time.deltaTime * 6;
 
             if(pos.x < -7) {
                 pos.x = 7;
             }
 
             objTransform.localPosition = pos;
     
         }
 
     }
 
 
     void FixedUpdate() {
 
         if(movementMethod == 0)
         {
             this.rigidbody2D.velocity = velocity;
 
             if(objTransform.localPosition.x < -7.0f)
             {
                 objTransform.localPosition = new Vector3(7.0f, 0, 0);
             }
         }
     }
 }
 


Thank you for looking in to this. I believe this is really a major issue that is probably affecting so many people and I'm really surprised it isn't being discussed more.

I have fiddled around with target frame rate, vsync and any other settings that I could.

Comment
Add comment · Show 6
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 Eric5h5 · Aug 28, 2014 at 06:22 AM 0
Share

I've never seen any "stuttering" when manually moving objects that wasn't caused by excessive garbage collection or instantiating objects for the first time. Looks fine to me.

Physics by default is 50 fps, so if the framerate is higher, then physics won't update every frame. In which case you should use interpolation or increase the physics framerate.

avatar image theProtagony · Aug 28, 2014 at 05:11 PM 0
Share

Hello Eric5h5. Thanks for your response. Were you able to try this on Android? Look closely for a few $$anonymous$$utes.. On my end, I see this on my $$anonymous$$acBook Pro (in Editor) and Tab 3 7" / Nexus 7

avatar image AlwaysSunny · Aug 29, 2014 at 06:31 AM 0
Share

Objects may appear to stutter when the distance they travel in a given frame is too great for the human eye to compensate for. Is it remotely possible that's what's going on for you?

avatar image smoggach · Aug 29, 2014 at 01:26 PM 0
Share

I hope you're disabling your rigidbody before trying to use method 1.

The first thing I notice is that you're using localPosition with method == 1. The object's parent may be the one causing the stuttering in this case.

Here are some other things to try if you haven't already: Vector3.SmoothDamp, RigidBody2D.$$anonymous$$ovePosition, Vector3.Lerp

Have you made sure you experience the stuttering on your target platform? I find stuff always runs like crap in the editor but devices have no problem.

You may also want to try driving your object with forces ins$$anonymous$$d of velocity. Good luck!

avatar image frogsbo · Aug 29, 2014 at 03:03 PM 0
Share

unless 2 methods in unity for example physics are interfering, the transform is always smooth to the very pixel.

obviously you are telling the object to do more than change position.

Show more comments

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

6 People are following this question.

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

Related Questions

2D Vector Movement,Vectorel Movement with Buttons 2 Answers

Can anyone maintain smooth 60fps on Android (2D) ? 0 Answers

Android based ARCore example ObjectManipulation using Joystick Controller 0 Answers

How to change movement script for computer for android. 1 Answer

Android APK acts different than in Editor 1 Answer


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