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 dansav · Feb 09, 2015 at 02:56 AM · camerafollowsmoothjerky

follow camera is jerky for other objects

I'm using the following code to have a camera follow an object. Whichever object the camera is looking at is followed smoothly, but other objects in the scene appear to have jerky movement. If I turn it off all objects move smoothly.

target is the gameObject I want to look at. offsetVector is Vector3(0,10,40); is to position the camera above and away from the target.

worldCameraObject.transform.position=Vector3.Lerp(worldCameraObject.transform.position,target.transform.position
+offsetVector,.5);
worldCameraObject.transform.LookAt(target.transform);

This is in the update loop.

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 meat5000 ♦ · Feb 09, 2015 at 02:59 AM 0
Share

What's offsetVector and have you tried any other value other than 0.5 for t?

avatar image incorrect · Feb 09, 2015 at 03:56 AM 0
Share

Is your camera set as a child of a target?

Also, try to use Time.deltaTime in lerping ins$$anonymous$$d of that 0.5, that will help make camera movement framerate-independent.

avatar image Joyrider · Feb 09, 2015 at 09:20 AM 0
Share

I made up a simple scene with your code, but the movement is not jerky on my end. So my guess is, it is linked to something else in your scene... Is the animation jerky only if you move the target, or at all times?

avatar image dansav · Feb 09, 2015 at 06:36 PM 0
Share

Joyrider: Thanks for taking the time to try and verify it. I have three objects in my scene one object is forcing the other two to move to the right, the other two look jerky but the target object does not. Changing the lerp doesn't help.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by renaissanceCoder1 · May 19, 2015 at 06:28 AM

This can happen if both your camera and object it is looking at are both updating in Update(). You will want your camera to update after the object is looking at is done making its movements. So put your camera update code in LateUpdate().

Comment
Add comment · Show 1 · 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 dansav · May 19, 2015 at 03:19 PM 0
Share

Cool thanks.

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

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

Camera follow smoothness problem 1 Answer

Smooth Follow Problem 1 Answer

Why does the camera smoothly follow in one direction but not the other? 0 Answers

[Closed] SmoothFollow trouble 0 Answers

Need help/advice with 2D Camera follow script. 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