Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved How to rotate only y-axis with Quaternions.

Discussion in 'Physics' started by Crazybrownie204, Feb 26, 2024.

  1. Crazybrownie204

    Crazybrownie204

    Joined:
    Mar 22, 2021
    Posts:
    38
    I am making a game that involves a character on a pogo stick who leans to make it move. My problem is that I can't seem to both rotate the character the same direction as the camera and make the leaning work. The camera I am using is the cinemachine 3rd person camera, and so I can either make the character have the same rotation as the camera, or use rigidbody.AddTorque to lean the character, but not both.

    Some things I have tried:
    • Putting the camera rotation in a parent of the player (Rigidbody isn't on it, so the rest of the player moves away without it, and still doesn't work anyway)
    • Setting transform.rotation to playercamera.rotation and using rigidbody.AddTorque (camera rotation constantly resets any rotation)
    • Using rotation constraint (Isn't working with transform.rotation = playercamera.rotation?)
    Please help, ive tried so many things and nothing is working.