- Home /
 
Impossible to get perfectly smooth camera movement?
I can't believe this, but for some reason, I cant get truly smooth camera following in Unity. I don't know what I'm doing wrong.
So, to make things simple, this is basically how to reproduce what I am seeing.
1.Make a box collider-rigidbody with interpolation turned on and mass set to 1400.
2.Add a script to push the box in a direction:
 function Update () {
 rigidbody.AddForce(Vector3(4000,0,0));
 }
 
               3.Now add a camera follow script. Something extremely simple like this:
 var target:Transform;
 function LateUpdate () {
 transform.position=Vector3.Lerp(transform.position,target.position,10*Time.deltaTime);
 }
 
               What you will see is the box getting closer and further from the screen as if the delta time was coming in at random.
I have tried several different timing variables, each in a different update function, and it's always this jerky movement no matter what I try.
Answer by Rush3fan · Feb 05, 2012 at 12:03 AM
I guess I'm going with a different approach that doesn't use smoothing. It will still look good, but I'll have to add in my own Z factor that will just be a simple smooth velocity based float. The camera movement will look less natural, but oh well.. It's not like I really need it anyway.
Ok, here's the deal. I finally figured out what I was supposed to be doing, but it's too late for now. Anyway, just in case someone else is having the same problem with lerp, you are actually supposed to use smooth damp. It's too bad no one knew that. =/ Smooth damping should be a very important part of game development. http://unity3d.com/support/documentation/ScriptReference/Vector3.SmoothDamp.html
Thanks for that, I was having issues with the "smooth follow" script myself. Problem solved :D
This is a years old post now, but it totally solved my issue, thanks!
Answer by Meltdown · Feb 04, 2012 at 06:06 PM
Firstly, you should be calling your physics related functions in FixedUpdate(), not Update().
I'd also suggest looking at the SmoothFollow camera script that comes with Unity, it works fine for me following rigidbodies with forces applied to it.
Alright.. I changed the physics part to FixedUpdate. Still had nothing to do with making the camera more smooth.
BTW: this is what the smooth follow script does:
transform.position -= currentRotation Vector3.forward distance;
That's not exactly smoothing out the camera's local Z.
Your answer
 
             Follow this Question
Related Questions
Very jerky camera movement with rigidbody 1 Answer
Disable Camera Movement,Stop camera movement 0 Answers
Choppy Camera Follow 1 Answer