Camera Jitter / Stutter


Is it possible to use Rigidbody.MovePosition instead of velocity to move a character followed by the camera without any stutter / choppiness? I’ve been searching for days :frowning:

Exactly the same problem as here:

Enabling ‘interpolate’ fix half of the stutter:
'While interpolation, horizontal translation in FixedUpdate and LateUpdate completely fixes the jitter on y axis, both on player and the scene, they introduce jitter on the x axis. ’

Setting the velocity fix the problem but this is discouraged because it may break the physic, so i’d prefer avoiding it.

The project is 3d platformer, with lot of fast movement, run, jump, so stutter is really important.

Thanks! This forum is a really strong help.

Instead of parenting the camera directly to the character, why not make the camera interpolate towards the character’s position over time? This would smooth out the camera movements and remove the stutter from the visuals.

If you set the lerp speed to be fairly high, then the position of the camera should be pretty similar to before as well.

I tried your script and it seems to work fine for me changing LateUpdate to FixedUpdate. The difference between the deltaTime calculated values in the camerascript and the fixedupdate-updated values of the player causes a small oscillation around the maximum distance point, which is basically your object jitter. You can see this when you Debug.Log the distance. In FixedUpdate this value becomes pretty fixed when moving.

If you really really want to use Update() or LateUpdate() you can try this:

Make a timer in FixedUpdate which records the total fixedDeltaTime passed since the code had last run in Update. Use this variable instead of Time.deltaTime in the code and reset the timer when you are done with the data.

This should help sync up the number of steps calculated for the player with the steps moved by the camera.

void Update()
    Vector3 camForwardZ = transform.forward;
    camForwardZ.y = 0.0f;        
    float currentDistance = Vector3.Distance (transform.position, player.position);            
    transform.position = transform.position + ((camForwardZ * (currentDistance - distance_max)) * 3f * timer);            
    transform.position = new Vector3(transform.position.x,  transform.position.y + ((player.position.y + height) - transform.position.y)*timer*2f , transform.position.z); 
    transform.LookAt (player.position);        

float timer = 0.0f;
void ResetTimer()
	timer = 0.0f;
void FixedUpdate()
	timer += Time.fixedDeltaTime;