• 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 British89 · May 25, 2012 at 02:31 PM · cameracontrollerfollowspaceship

Camera Shaking At High Speed

Hello,

Im in the middle of making a space sim, But i seem to be having problems with the camera, It follows the ship and pulls away from the ship as the ship gets faster, But when the ship is at max speed the samera seems to shake, At first i thought it might be the ship controller script causing the ship to shake but i guess not, Can someone have a look at this code and see if theres anything wrong? Thanks.

 var target : Transform;
 
 var distanceToFollow : float = 5.0;
 
 var height : float = 1.0;
 
 var moveSpeed : float = 1.0;
 
 var rotationSpeed : float = 1.0;
 
  
 
 private var targetRay : Ray;
 
  
 
  
 
 function Update () {
 
  
 
     //move the camera into position behind the target
 
     targetRay = new Ray(target.position,-target.forward);
 
     point = targetRay.GetPoint(distanceToFollow);
 
     point = Vector3.Slerp(transform.position, point, Time.deltaTime * moveSpeed);
 
     transform.position = point;
 
     
 
     //rotate the camera to match the rotation of the target 
 
     transform.LookAt(target,target.up);
 }
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
0

Answer by TowerOfBricks · May 25, 2012 at 02:47 PM

This is probably because first, your camera object adjusts its rotation to look at the object, then your object moves a tiny bit in its update step, next the scene is rendered, now the camera will not look exactly at the object since it moved a bit. To solve this, put the camera updating code in LateUpdate instead of Update.

Comment
Add comment · Show 8 · 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 British89 · May 25, 2012 at 02:58 PM 0
Share

I changed it around a bit and put it in the LateUpdate function and it didn't seem to change anything, If anything it seemed to make things worse, Are cameras not supposed to move at high speed?

avatar image TowerOfBricks · May 25, 2012 at 03:01 PM 1
Share

Try removing that Slerp call and see if it makes it better. In high speeds that might cause things to vibrate because of different Time.deltaTime values (I think at least).

avatar image British89 · May 25, 2012 at 03:29 PM 0
Share

I removed the Slerp and it made no difference, Dose everything seem ok to you in the script i posted? Or is there a better way to do it?

avatar image British89 · May 25, 2012 at 04:27 PM 1
Share

Problem solved, Aron Granberg told me to change the function Update to LateUpdate And it didnt solve the problem, So i though i might aswell try the FixedUpdate function and it seems to have solved the problem. As smooth as it can get. Thanks.

Aron Granberg can you edit your answer to FixedUpdate so i can mark it as a correct answer, Thanks.

avatar image wade-chiou British89 · Jan 05, 2016 at 03:07 PM 0
Share

Thank you! It solved my problem too.

$$anonymous$$y situation is.. when using follow-came(setting camera directly to a location), camera did not shake. But camera for mirror is shaking. (so the image in the mirror is shaking simultaneously)

avatar image wade-chiou British89 · Jan 05, 2016 at 04:06 PM 0
Share

I tried it again. Update velocity of rigid body in method "FixedUpdate", then update follow camera in method "LateUpdate". And interpolate can not be null. it works too.

avatar image Xeong-Hu · Feb 01, 2015 at 07:42 AM 0
Share

Yep solved my problem too

Show more comments

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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Related Questions

Weird Camera Follow Problem 1 Answer

Rotate spaceship based on mouse movement 2 Answers

Camera following Pivot not working 1 Answer

camera follow an game object 0 Answers

Camera Follow Mouse 2 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