- Home /
Uneven camera movement during roll
I have a camera inside a cockpit that Slerps to match the cockpit's orientation. This provides a nice sway effect when flying but produces a laggy/ uneven movement during a roll.
I have narrowed the culprit down to the up vector of the Slerp. The camera needs to match the cockpit's Transform.up vector but this causes a jagged motion only during a roll. This problem goes away if both the camera script and cockpit script use FixedUpdate() but since rigidbodies are not used, this creates other problems elsewhere.
I have also dug through a ton of other questions looking for something that might help me but to no avail. Any help would greatly appreciated.
The camera's C# script:
// Update is called once per frame
void LateUpdate ()
{
//smooth upVector to try to prevent jitter
upVector = Vector3.SmoothDamp(upVector, target.up, ref smoothVelocity, 0.1f);
//slerp to match cockpit rotation
myTransform.localRotation = Quaternion.Slerp(myTransform.localRotation,
Quaternion.LookRotation(target.forward, upVector),
Time.deltaTime * reboundSpeed);
//match cockpit position
myTransform.position = target.position;
}
How I'm getting my roll value in the cockpit's controller script Update() function:
//smooth the roll input
roll = Mathf.Lerp(roll, Input.GetAxis("Horizontal") * 2, Time.deltaTime * 5 );
//ship rolls from roll input
shipTransform.Rotate(0,0,-roll);
Update - Turning on Vsync seems to eli$$anonymous$$ate these small motion jitters. Is it possible that the jagged motion is really screen $$anonymous$$ring? I would like to be able to have smooth animations without Vsync but I'm not sure that is possible.
Your answer
![](https://koobas.hobune.stream/wayback/20220613162148im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Camera shake 2 Answers
Jitter Camera Effect When Parented To Animated Object 2 Answers
Jumpy object movement and camera movement 1 Answer
How to lock camera roll in C# 1 Answer
Object jitters when camera is moving and is in the near? 0 Answers