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 sysameca · Mar 29, 2015 at 07:16 AM · camerarenderingupdatejitterlateupdate

Update/Late Update jitter problem(non FixedUpdate related)

Hey guys i am experiencing an issue where an object placed on the scene follows the main camera and jitters if the camera moves in the LateUpdate() method. The way i understood is late update gets called once per frame after Update() is finished, so there should be really no problem moving the object like that. The way i created the scene:

  1. Create a new empty scene.

  2. Set the camera to orthographic and attach this script to it:

      public class CameraMoverTest : MonoBehaviour
       {
         private void Update()
         {
             transform.position += new Vector3(1, 0, 0) * Time.deltaTime * 20;
             Debug.Log("Camera Position X: " + transform.position.x);
         }
     
         //// Jitters
         //private void LateUpdate()
         //{
         //    transform.position += new Vector3(1, 0, 0) * Time.deltaTime * 20;
         //    Debug.Log("Camera Position X: " + transform.position.x); 
         //}
      }
    
    

    3.Create a new game object, add SpriteRenderer component and add some sprite to visualize the jitter and add this script to the same game object:

     public class MovedObjectTest : MonoBehaviour
     {
         private Vector2 m_initialPosition;
     
         private void Start()
         {
             m_initialPosition = Camera.main.transform.position;
         }
     
         private void Update()
         {
             Vector3 position = Camera.main.transform.position;
             position.z = 0;
             transform.position = position;
     
             Debug.Log("Object Position X: " + transform.position.x);
         }
     }
     
    

So the object does not jitter if the camera moves in the Update() method, but if you uncomment the LateUpdate() method and comment the Update() you will see a noticeable jittery movement over the X axis of the moving object. Both debug logs shows exactly the same camera and object positions. I can't really see where the problem is. What am i doing wrong? Please explain.

EDIT: So i did some test and came up with some observations. It seems its something to do with the order of execution.

Observation 1

Moved Object - Updating Method : LateUpdate()

Camera - Updating Method : LateUpdate()

Result: Jitter

Observation 2

Moved Object - Updating Method : LateUpdate()

Camera - Updating Method : Update()

Result: NO Jitter

Observation 3

Moved Object - Updating Method : Update()

Camera - Updating Method : Update()

Result: Jitter

Observation 4

Moved Object - Updating Method : Update()

Camera - Updating Method : LateUpdate()

Result: NO Jitter

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

Answer by Nanity · Mar 29, 2015 at 08:46 AM

Option #4 is the correct execution. See http://docs.unity3d.com/ScriptReference/MonoBehaviour.LateUpdate.html

In Options #1 and #3 you need to take care of the script execution order. Generally a bad advice to rely on this. http://docs.unity3d.com/Manual/class-ScriptExecution.html

Option #2 basically is the same as #4, but either the camera or the object is behind one frame regarding the movement.

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

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

Stacked cameras not working after update 2018.3 -> 2019.2 0 Answers

How can I get my camera to momentarily pause between different positions when using lerp? 0 Answers

Is my (LateUpdate) camera + rigidbody causing jitter? 2 Answers

How would you render a seemlessly wrapping scene? 1 Answer

Unity - Render XR game objects onto processed camera image 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