Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Wolfone · Aug 18, 2017 at 08:57 AM · camera movementsmoothing

Possible reasons for lacking smoothness of horizontally moving cam

Hello everyone,

I am currently a little bit helpless with my tries to smooth a certain camera-movement, which is jittery right now. The movement is horizontal along a fixed line and shows a simple 3D map made mostly of cubes and some instances of more elaborate models. After reading a little bit in other threads I tried Lerping to smooth everything out but it didn't really do the trick (maybe i used it wrong, i don't know). For starters my initial version (context: move cursor to side of monitor->cameramovement horizontally)(EDIT:sorry for the looks of the code...in the preview it looked fine and i don't know how to fix this):

 tempPosition = transform.position;
 
 if ((Input.mousePosition.x>screenWidth-activateScrollOffset)&&(tempPosition.x>rightBoundary)) 
 {
     tempPosition.x = tempPosition.x - scrollSpeed * Time.deltaTime;
     transform.position = tempPosition;
 }

(Just one side for reference needed, i think.)

How I tried with lerping:

 if((Input.mousePosition.x>screenWidth-activateScrollOffset)&&(tempPosition.x>rightBoundary))
 {
   tempPosition.x = tempPosition.x - scrollSpeed * Time.deltaTime;
   transform.position=Vector3.Lerp(transform.position,tempPosition,Time.deltaTime*scrollSpeed);
 }

This is placed in Update(){...}. Additional information:

I think the effect is mostly visible when there are more objects on the screen which made me think it may be an issue of too complex objects but the monitoring shows a nearly constant framerate around 65 fps +/-3 and the jittering is just too high to come from this little difference i think. I'm not doing anything which would be considered "grafic-intense" for an upper middle class pc. The effect occurs for example in situations where only around 48k vertices are shown and in some places doesn't show with much more vertices on screen. According to the doc a decent pc should be able to handle several millions.

So..I would really appreciate any ideas how to improve this. Thanks in advance!

Comment
Add comment · Show 4
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 · Aug 18, 2017 at 10:42 AM 0
Share

A camera should always be moved in LateUpdate. That's because at that time all other movement has finished. This can cause lag, not from the camera, but the inconsistency in movement relative to other moving objects.
It won't get any smoother than multiplying a speed with Time.deltaTime, because mathes any speed up to per second.
I shortened the code to the relevant parts.

  if ((Input.mousePosition.x > screenWidth-activateScrollOffset) && (transform.position.x > rightBoundary)) 
  {
      transform.position -= scrollSpeed * Time.deltaTime;
  }
avatar image Wolfone · Aug 18, 2017 at 02:08 PM 0
Share

Hello hexagonius, thanks for your reply! Your explanation sounds logical to me but unfortunately I still have the same effect after moving to LateUpdate. Any other things i could check on?

avatar image hexagonius Wolfone · Aug 18, 2017 at 08:03 PM 0
Share

Remove the if statement to see if the camera auto moves smooth then. If not, the check is bogus

avatar image Wolfone hexagonius · Aug 19, 2017 at 08:52 AM 0
Share

Unfortunately no improvement...

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

68 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 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 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

Multiplayer: jitter caused by camera? by smoothing? 2 Answers

Gradually reduce speed 1 Answer

Rigidbody 2d smooth movement problem (It's jerky) 1 Answer

Using CameraControl.cs on android platform 0 Answers

Camera following player without rotation 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