Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Camera- and CharacterMovement - Need Help with "look up and down"

Discussion in 'Scripting' started by Cellenseres, Oct 4, 2017.

  1. Cellenseres

    Cellenseres

    Joined:
    Mar 30, 2015
    Posts:
    67
    Hey Guys,

    Right now I'm working on a small First Person RPG Project.
    I wrote a Script to move the character on the x- and z-axis with WASD/D-Pad/Left Control Stick & rotate the character on the y-axis with Q & E (L & R Button).

    Now I want to rotate the Camera with a second (Right) Control Stick without rotating the player.
    I want to be able to rotate the camera for ~140° on the y-axis (70° left, 70° right) and ~90* on the x-axis (45° up, 45° down).
    Code (CSharp):
    1.             Camera.transform.Rotate(0 , rh * rotateSpeed, 0);
    2.             Camera.transform.Rotate(rv * rotateSpeed , 0, 0);
    I have a blackout and forgot how to limit the rotation + set the rotation back to 0 when right control stick is not used.

    Could you help me out?
    22195789_10214067047930843_124846793483603948_n.jpg
     
    Last edited: Oct 4, 2017
  2. fire7side

    fire7side

    Joined:
    Oct 15, 2012
    Posts:
    1,819