I changed the lateupdate to fixedupdate and it fixed the problem. But now when I walk everything seems fine but I see a slight blur kind of thing on the zombie when I start moving, it is a very little shaky still. Any idea? It seems like the camera follow is not at full frame rate so it seems laggy a bit still.
Rigidbodies move in FixedUpdate, Rendering happens in Update. Maybe your player and your enemy are moving in different updates - so if the camera stands still, everything looks good, if it is moving, one or the other seems laggy.
You can fix this by interpolating your camera velocity, so the cam has its own movement speed.
This is from a 2D project, but the theory for 3D is the same:
transform = player, camTransform = camera transform - just to avoid confusions.
Players Rigidbody-Interpolate is set to “Interpolate”
Yes, as @John_Leorid says, this problem comes from having the camera and the follow object in differents timestep updates. Also, if any other object (like your zombie) is in a different timestep than the camer, it will jitter if both are moving.
Using Rigidbody.Interpolate may do de trick, but you will need to use it on every Rigidbody that is jittering, and depending on your target platform it may lead to some bad performance. Also, moving your camera in FixedUpdate will result in a not as smoothy movement like it was in Update.
Have you considered using CharacterController component for movement instead of Rigidbody? It may be very handy if you are not developing a physics-driven game, and you can move it in Update and get rid of this mess with timesteps. Also, it has some nice parameters to control the max slope a character can walk, or the max height a character will “step up” (among other cool things). If you are interested in, take a look to this link Unity - Manual: Character Controller component reference
When I use this script my camera goes slowly into the ground.
I want my player to collide with walls, zombies etc so I will need a rigidbody. But I am getting so anoyed by this lagging/blurring zombie. The zombie is using a navmeshagent.
CharacterController handles collision, you can use it without needing any further Collider or Rigidbody. If you need a Rigidbody because you want to listen to OnCollisionEnter events, just tick rigibody’s IsKinematic to avoid any physic calculation like gravity or so on, since CharacerController will handle them too
Move your player and enemies inside Update method (not FixedUpdate).
Move your camera inside Update method (not FixedUpdate), or even better inside LateUpdate method.
Use CharacterController for movement instead of Rigidbody, since Rigidbody should be moved inside FixedUpdate and now you want to move your character inside Update rather than FixedUpdate.
If you still want to have a Rigidbody component attached to your object, make sure to tick te IsKinematic option in the Inspector since you are handling movement with CharacterController.
If after following this steps doesn´t work, please paste your code so I can check it out
Thank you, the problem was I was doing it in fixedupdate with the character controller! Now I’ll have to figure out how to make my character controller work properly because it sucks now.
I am using this to move, but it is very weird. In some directions my player moves slowly, randomly speeds up again. It is just not good, do you see any problems?