x


Main Camera Rigidbody Jerkiness when attached to Player Character

So, I have a clever movement controller that uses rigidbody relative torque and relative force. It works very well, and I am happy with it.

The problem, however, is attaching a camera.

For the longest time I applied this script to the camera, which carried the player mesh inside its hierarchy.

Now, however, I wanted some slack / pull to the camera, so as you turn your character, the camera lets you see the side of your vehicle for a moment before it snaps behind you. So, I decided on a configurable joint. I've finally gotten the joint to what seems like good parameters, however, the biggest problem in this situation seems to be the rigidbody values of mass and drag, as well as to an extent, my speed/force multipliers in my movement controller.

Now I have the player character and main camera separate, with the joint on the player, and the camera as its 'connected body.'

I've looked up the docs, and interpolation exacerbates the issue.

more ▼

asked Feb 12 '10 at 01:41 PM

CryptoQuick gravatar image

CryptoQuick
57 6 8 13

Just to be clear, folks, this is most likely related to the configurable joint being added to the moving vehicle. It's also got to relate to mass and drag, because I noticed this also changes how things work.

Feb 13 '10 at 06:05 PM CryptoQuick
(comments are locked)
10|3000 characters needed characters left

2 answers: sort oldest

One time I noticed camera jerkiness because the camera's transform was being updated in the Update function and I'd forgotten to multiply it by Time.deltaTime. Placing it in a FixedUpdate function also worked. It could be something having to do with the way physics calculations are updated. Maybe rather than make the camera a part of the joint system you could try:

  1. Making the camera its own, independent object again (like the default Main Camera)
  2. Putting a dummy GameObject where the camera used to be, in the joint system
  3. Adding a script to the camera that sets the transform of the camera to that of the dummy GameObject in the FixedUpdate function:

var dummyObj : GameObject;

function FixedUpdate() {
    transform = dummyObj.transform;
}

or maybe put that transform sync in a LateUpdate() function. Just shooting in the dark, let me know if it works!

more ▼

answered Feb 12 '10 at 11:35 PM

Design3.com gravatar image

Design3.com
640 1 1 10

Actually, all my force code that affects movement of the vehicle is in the FixedUpdate function. In fact, everything worked fine up until the point where I added the configurable joint. Maybe I should make this more clear.

Feb 13 '10 at 06:03 PM CryptoQuick
(comments are locked)
10|3000 characters needed characters left

If all else fails, lower the Fixed Timestep in Edit->Project Settings->Time.

more ▼

answered Feb 13 '10 at 06:11 AM

AquaGeneral gravatar image

AquaGeneral
287 3 4 20

(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:

x3000
x1790
x63

asked: Feb 12 '10 at 01:41 PM

Seen: 2108 times

Last Updated: Feb 13 '10 at 06:06 PM