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
1
Question by Tjandy98 · Oct 22, 2013 at 08:06 AM · c#camerashaking

Issue with camera (Shaking)

Someone explain this mistake!

Video : http://www.youtube.com/watch?v=8YK2IofeUgY

Code used :

 using UnityEngine; 
 using System.Collections; 

 public class CameraControl : MonoBehaviour 
 { 
   public Transform target; 
   public float distance = -10f; 
   public float lift = 1.5f; 
   void Update() 
   { 
      transform.position = target.position + new Vector3(0, lift, distance); 
      transform.LookAt(target); 
   }
 }
Comment
Add comment · Show 7
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 btb200 · Oct 22, 2013 at 08:42 AM 0
Share

are you sure that camera is shaking? check values of position in Inspector on run. What is your target object?

avatar image thef1chesser · Oct 22, 2013 at 09:01 AM 0
Share

$$anonymous$$eep your scene open as well and select camera so you can see what the camera is doing compared to the objects.

avatar image sethuraj · Oct 22, 2013 at 09:07 AM 0
Share

Use 'SmoothFollow' Script under Unity Standard Assets>Scripts>Camera to get started.

avatar image sdgd · Oct 22, 2013 at 09:11 AM 0
Share

I can see there's more to that than just this script because you are moving camera toards the target

are you by any chance multiplying camera rotation with time.delta time? or something at that stuff?

I know because I had same issue, ...

avatar image AlucardJay · Oct 22, 2013 at 09:44 AM 1
Share

Try using LateUpdate so the camera moves after everything else does. Also (as suggested by sethuraj use the SmoothFollow script), consider lerping ins$$anonymous$$d of hard setting the position :

 transform.position = Vector3.Lerp( transform.position, target.position + new Vector3(0, lift, distance), 0.95 ); // use a float between 0 and 1 for lerp factor

  • http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$onoBehaviour.LateUpdate.html

  • http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Lerp.html

Show more comments

2 Replies

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

Answer by hirenkacha · Oct 24, 2013 at 11:47 AM

Simply use LateUpdate() instead of Update() for camera script.

Comment
Add comment · Show 5 · 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 Tjandy98 · Oct 24, 2013 at 12:20 PM 0
Share

Wow!Brilliant!This is it!

Can you explain why does this happen?

And thanks to everyone!

avatar image vexe · Oct 24, 2013 at 12:26 PM 1
Share

@Tjandy98 if you read the comments, you'll notice that @alucardj has already told you to do so.

avatar image Tjandy98 · Oct 24, 2013 at 12:39 PM 0
Share

@vexe

Yeah at that time I was confused,and now I und

avatar image hirenkacha · Oct 25, 2013 at 04:04 AM 0
Share

@Tjandy98 it happens due to referencing and transfor$$anonymous$$g position and rotation of two objects simultaneously in Update Function. So in Update let the target get transformed and in LateUpdate() let camera get refer to that position. So this is done turn by turn.

avatar image sonalvasu · Apr 09, 2018 at 08:19 AM 0
Share

Still its shaking little bit.Can you tell me what is reason behind it?

avatar image
1

Answer by luckruns0ut · Oct 22, 2013 at 12:11 PM

Try unparenting the camera, if you haven't done so already.

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 Tjandy98 · Oct 24, 2013 at 11:34 AM 0
Share

Guys,please download my project,I don't understand I tried it too,but the camera have like 5 lines please help!!

http://www.megafileupload.com/en/file/463289/ProjectLearning-rar.html

Someone please explain :(

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

24 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

Related Questions

Distribute terrain in zones 3 Answers

Collider/Rigidbody issue.Camera shaking! 3 Answers

Multiple Cars not working 1 Answer

I need help with TPS controls! 0 Answers

How to make the Health bar on Enemys head not be in relation to Player(main) Camera? 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