Camera stutters a lot when looking around (need help)

Hello,

I’ve looked everywhere about this and tried a lot of things but havent found a solution. Basically I have a first person controller in my game and when I enter game mode the camera stutters like crazy. Any answers to my questions will be greatly appreciated. The controller I’m using is one I donwloaded here it is:

Can you post the code you’re using?

Some things to check/try:

  1. Use LateUpdate() to move your camera. Sometimes using Update() loop can be an issue.
  2. Make sure you put the LookAt() code AFTER the code where you move the camera. This is more pronounced in higher speed objects.
  3. Use Quaternion.Slerp (or Quaternion.Lerp) to smooth the camera movement. Mmake sure the movement speed isn’t too high. Example:
private Transform lookAt;
private float smoothSpeed;

void Start()
{ 
        lookAt = GameObject.Find("Player");
if (smoothSpeed < .1f)
        smoothSpeed = 2;
}

void LateUpdate()
{
        // Remember to move first //
        camera.transform.position += new Vector3(10,10,10); // This can be whatever your camera movement logic is. 

        // Then LookAt last. Always do LookAt last. //
        // Otherwise you're turning the camera at location A, then moving the camera location B. Subsequently, the camera probably is pointed at the wrong thing //
        lookAt.LookAt(player.position);  
        transform.rotation = Quaternion.Slerp(transform.rotation, lookAt.rotation, (Time.deltaTime * smoothSpeed));        
}

Note: If you’re not using the Time.deltaTime modifier, then that will essentially nullify the benefits of Slerp/Lerp

Hi thanks for the reply. I uploaded the images from the script I’m using. Also my controller has several parts I also uploaded an image about that. Also I am not that familiar with Unity, I only started a month ago so I don’t understand what you’re saying. Thanks for your time!

6142305--670341--Script1.PNG.jpg
6142305--670344--Script2.PNG.jpg
6142305--670347--Script3.PNG.jpg
6142305--670350--Script4.PNG.jpg
6142305--670353--Untitled.jpg

Hi. Only been doing this a month, eh? Welcome to the asylum. I started banging my head against the Unity wall a couple years ago. Hardly notice the concussion anymore. Published my first game a month ago. Have since learned a bunch of better ways I could have wrote since then.

From the screen shots you provided, it would seem as if you’re using an existing project that you didn’t write yourself. There isn’t anything wrong with that. It’s a great way to learn. While you did post what I requested, there is unfortunately more I would need to see to begin diagnosing the issue.

Since you didn’t understand what I suggested in my first post. Forgive me for being presumptive, but I am guessing you’re still getting your footing with the programming aspects of Unity. I would recommend doing some of the free tutorials Unity has online. They’re surprisingly good. I think jumping into the middle of an established project like you are would be overwhelming to me, and like I said, I’ve been doing this for a couple years, and even published a (simple) game.

Good luck :slight_smile: