Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by stighy · Mar 19, 2016 at 01:28 AM · rotation

How to rotate camera based on player input

Hello at all. I would like to rotate camera based on user input. I explain: when user press classic up/down arrow, player is move, but i want also rotate main camera. It is not a player follow rule. At the moment i'm trying to rotate camera from Player MOvement script, but it not works. Here my sample code

 if (moveVertical > 0) {
             Camera mainCam = Camera.main;
             if (mainCam.transform.rotation.x <= 95) {
                 Vector3 target = new Vector3(mainCam.transform.rotation.x + 1, mainCam.transform.rotation.y, mainCam.transform.rotation.z);
                 mainCam.transform.Rotate (target);
             }
         }


I know i'm doing something wrong because 1) mainCam.transform.rotation.x not contain "classic" value from 1 to 360 degree. I read something about quaternion 2) rotation works but it continue to rotate because of problem nr 1

Thanks in advance for any ..tips ! Bye

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Le-Pampelmuse · Apr 19, 2016 at 01:59 PM 1
Share

Hi. It is not clearly undestandable what exactly your problem is here.

  • I would like to rotate camera based on user input
    -> http://answers.unity3d.com/questions/664282/use-inputmouseposition-to-rotate-camera.html

  • mainCam.transform.rotation.x not contain "classic" value from 1 to 360 degree
    ->Because it's a quaternion: http://answers.unity3d.com/questions/799824/oafatwhy-does-transformrotationx-45-not-work.html
    If you want angles in degrees, use eulerAngles or localEulerAngles respectively. If you already read that this has to do with quaternions, why are you wondering that it won't work? ;)

  • rotation works but it continue to rotate
    ->That's because the angle is not stored in degrees in a quaternion. It will stay between -1 and 1 so "x

I suggest you follow the official beginner tutorials before trying stuff on your own. You can find them in the Learn Section.

Have a nice day.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Smooth rotation on Y axis to target pose 0 Answers

Visible Rotation from controller 1 Answer

Rotate cube as if it were floating in the sea 1 Answer

Rotating a forward vector 0 Answers

Rotated object raycasting in wrong directions!!? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges