Search Unity

"Look rotation viewing vector is zero"

Discussion in 'Input System' started by Walrus446, Sep 3, 2022.

  1. Walrus446

    Walrus446

    Joined:
    Mar 26, 2021
    Posts:
    1
    I don't know why but my debug log is filled with this message. Here is my player movement. My character also keeps automatically being reset to a default position and I can't remember what I did to cause it.

    Code (CSharp):
    1.     void Start()
    2.     {
    3.         forward = Camera.main.transform.forward;
    4.         forward.y = 0;
    5.         right = Quaternion.Euler(new Vector3(0, 90, 0)) * forward;
    6.         detected = GetComponent<WallLighting>();
    7.     }
    8.  
    9.     void Update()
    10.     {
    11.         Move();
    12.      
    13.         if (detected)
    14.         {
    15.             Debug.Log("detected");
    16.             if (Input.GetKeyDown("e"))
    17.             {
    18.                 hasFlashlight = false;
    19.                 flashlightInsert = true;
    20.                 DestroyGameObject();
    21.             }
    22.         }
    23.     }
    24.  
    25.     void Move()
    26.     {
    27.         Vector3 direction = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis ("Vertical")); //takes horizontal/vertical button inputs and translates it to movement
    28.         Vector3 rightMovement = right * moveSpeed * Time.deltaTime * Input.GetAxis("Horizontal");
    29.         Vector3 upMovement = forward * moveSpeed * Time.deltaTime * Input.GetAxis("Vertical");
    30.  
    31.         Vector3 heading = (rightMovement + upMovement);
    32.  
    33.         transform.forward = heading;
    34.         transform.position += rightMovement;
    35.         transform.position += upMovement;
    36.     }