- Home /
Unity trail render attached to rigidbody is jittery
I tried attaching a trail renderer to my player, who is a rigidbody. No matter what I do I can't seem to prevent the trail from being jittery. My player moves by setting rigidbody velocity in FixedUpdate and rotates with rigidbody.MoveRotation() in FixedUpdate.
I've tried attaching the camera to the player, following the player with smoothdamp and lerp (in Update and in LateUpdate), and also tried setting interpolate/extrapolate on the rigidbody.
What is the correct way of doing this? Thanks!
Camera code:
void Update() {
Vector3 offsetPos = target.transform.TransformPoint(offset);
transform.position = Vector3.SmoothDamp(transform.position, offsetPos, ref vel, Time.deltaTime * speedDamp);
transform.rotation = Quaternion.Slerp(transform.rotation, target.transform.GetComponent<Rigidbody>().rotation, Time.deltaTime * rotationDamping);
}
Example Movement Code:
r.velocity = transform.forward * currentSpeed;
r.MoveRotation(r.rotation * newRot);
Your answer
Follow this Question
Related Questions
Rigidbody speed based on direction relative to camera 0 Answers
Moving a camera with AddFoce, or setting velocity, need help 1 Answer
Moving forward relative to camera with atypical WASD script, cinemachine, rigidbody and boxcollider 0 Answers
How to rotate a Rigidbody without rotating the gameObject? 1 Answer
TPS camera in multiplayer... 2 Answers