Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question My Camera is moving up and down, but not left and right

Discussion in 'Editor & General Support' started by unity_6D863B17F55C839A08C6, Feb 16, 2023.

  1. unity_6D863B17F55C839A08C6

    unity_6D863B17F55C839A08C6

    Joined:
    Feb 15, 2023
    Posts:
    3
    Ok, so I was making an first person game, and everything was working fine, until it crashed and i lost all my progress, so I made a new one. Now I inserted the same script into the new game. Now i cant rotate the camera from side to side. I can still move, jump, and look up and down.

    What i tried:
    -increasing the x look limit
    -changing the look speed
    -making the capsule (body) a child of the main camera.

    I apologize if this is a no-brainer, im new to unity.
    Here is the code
    Code (csharp):
    1.  
    2.         characterController.Move(moveDirection * Time.deltaTime);
    3.  
    4.         if (canMove)
    5.         {
    6.             rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
    7.             rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
    8.             playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
    9.             transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
    10.         }
    11.  
     
  2. unity_6D863B17F55C839A08C6

    unity_6D863B17F55C839A08C6

    Joined:
    Feb 15, 2023
    Posts:
    3
    dang it. I messed up. Sorry it looks like only mods can delete posts. dont reply. i figured it out
    if anyone comes to this thread with the same problem, put the script in your empty player object, not your camera
    apologies
     
    Kurt-Dekker likes this.
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,946