x


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!

more ▼

asked Jun 25 '11 at 10:07 PM

naf456 gravatar image

naf456
106 21 25 28

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jun 25 '11 at 10:38 PM

Heratitan gravatar image

Heratitan
314 20 22 29

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).

Jun 25 '11 at 11:03 PM aldonaletto

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 IMO) I may have to increase the damping if the quternion of the space ship changes violently, this may let me add more(less) damping.

Jun 27 '11 at 09:10 AM naf456

Re: Shaking/Ghosting, fiddle with rigidbody settings, particularly interpolation/extrapolation?

Jun 27 '11 at 10:01 AM runonthespot

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!

Jun 27 '11 at 10:53 AM naf456

Excellent- thanks for updating us.

Jun 30 '11 at 03:18 PM runonthespot
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3014
x316
x181
x31
x14

asked: Jun 25 '11 at 10:07 PM

Seen: 1233 times

Last Updated: Jun 30 '11 at 03:18 PM