Look rotation viewing vector is zero

Hi there, this question has been asked numerous times as I found by Googling the solution. However the solution everyone gave was to place the Quaternion within an if statement declaring

if(NextDir != Vector3.zero){}

The problem being that my Quaternion rotation is already inside that if statement and it still gives me the “error”

Here is my code I’m not sure exactly where the issue lies:

        CharacterController controller = GetComponent<CharacterController>();
        NextDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
        Quaternion wantedRotation = Quaternion.LookRotation(NextDir);
        if (NextDir != Vector3.zero)
        {
            this.transform.rotation = Quaternion.RotateTowards(this.transform.rotation, wantedRotation, rotateSpeed * Time.deltaTime);
        }
        NextDir *= speed;
        controller.Move(NextDir * Time.deltaTime);

Hi you are calculating LookRotation before sanity check.

  CharacterController controller = GetComponent<CharacterController>();
         NextDir = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));

         if (NextDir != Vector3.zero)
         {
        // Do not calculate rotation if dir is zero
         Quaternion wantedRotation = Quaternion.LookRotation(NextDir);
             this.transform.rotation = Quaternion.RotateTowards(this.transform.rotation, wantedRotation, rotateSpeed * Time.deltaTime);
         }
         NextDir *= speed;
         controller.Move(NextDir * Time.deltaTime);

This should remove your warning.