- Home /
Weird Camera Follow Problem
I have this weird camera follow problem, where as, my camera target slowly creep forwards till my spaceship is flying behind it. i don't know why- I've been itching my head all day. there is no silly rigidbody placements or alike I'll quadrupedly checked every property on my scripts, yet it still occurs. Here the proof : http://www.youtube.com/watch?v=jaUaZZ1buYA
here's my follow camera script:
var target : Transform;
var distance = 3.0;
var height = 3.0;
var damping = 5.0;
var smoothRotation = true;
var rotationDamping = 10.0;
function LateUpdate() {
var wantedPosition = target.TransformPoint(0, height, -distance);
transform.position = Vector3.Lerp (transform.position, wantedPosition,
Time.deltaTime * damping);
if (smoothRotation) {
var wantedRotation = Quaternion.LookRotation(target.position -
transform.position, target.up);
transform.rotation = Quaternion.Slerp (transform.rotation, wantedRotation,
Time.deltaTime * rotationDamping);
}
else transform.LookAt (target, target.up);
}
by the way, it'll also be nice kill two bird with one stone and to have an answers why the SSAO seems to draw lines on my ship aswell. Thanks for any replies!
Answer by Heratitan · Jun 25, 2011 at 10:38 PM
I'm not 100% sure about this but, what it looks like is that your ship is moving fast enough that at the rate your camera is following, it can not keep up. In other words: The damping is too high.
Try decreasing your damping and see if that works.
I hope this helps.
Yes, it looks like a typical feedback problem: at each update the differences between real and wanted position/rotation are calculated and used to correct the camera (it's done by the lerp and slerp functions). At some combination of correction "gain" and speed, the system starts to oscillate. You must slow down the camera movement to avoid this oscillation - reduce the damping and/or rotationDamping values (reducing them actually increase the system damping).
It's kinda solved that, but now I get this Ghosting effect were as my spaceship looks like it's violently shaking all the time. Problem after problem ey? Also, I've seen other youtube video's with space ship in- they have ton's of damping?(a little too much I$$anonymous$$O) I may have to increase the damping if the quternion of the space ship changes violently, this may let me add more(less) damping.
Re: Shaking/Ghosting, fiddle with rigidbody settings, particularly interpolation/extrapolation?
No-it wasn't the rigidbody, because when the camera was attached to the ship as a child, the shaking do not occur. I finally fixed that problem from taking the camera function off of LateUpdate to FixedUpdate. this may cause problems with low framerate as the camera may return out of sync again. Also now I have that weird alignment problem I had before. No matter how High I set the Dampen value, it Never stays aligned (-nor how slow I turn). This is REALLY starting to anoy me. I thought the Camera was the easiest thing to setup!
Your answer
Follow this Question
Related Questions
Camera Shaking At High Speed 1 Answer
Rotate spaceship based on mouse movement 2 Answers
Super Monkey Ball type Camera? 2 Answers
Camera setup question 2 Answers
In-world "screen" from camera? 1 Answer