Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Feb 16, 2015 at 09:18 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Avanak · Feb 16, 2015 at 10:43 AM · c#cameracamera-movementcamera rotatecamera-look

Free camera look question

I am making a space game where I want the player to be able to navigate a 3d map of all the stars. For this I made a simple script that translates the mouse X and Y axis into a change in localEulerAngles. It works perfectly, however when you move the mosue upwards and "flip" upside down, the movement is inverted. This makes total scense of course, but I don;t know how to fix it.

Here is my code

 xRot += Input.GetAxis("Mouse X") * xSensitivity;
 yRot -= Input.GetAxis("Mouse Y") * ySensitivity;
         
 Vector3 newRot = new Vector3(yRot, xRot, 0);
         
 transform.localEulerAngles = newRot;

Anyone who can help me?

Many thanks!

Comment
Add comment
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

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by Avanak · Feb 16, 2015 at 09:18 PM

I found the answer for myself. I used Vector3.up and Vector3.left to generate rotation.

 transform.Rotate(Vector3.up * Input.GetAxis("Mouse X") * xSensitivity);
 transform.Rotate(Vector3.left * Input.GetAxis("Mouse Y") * ySensitivity);

Anyway, many thanks for the help!

Comment
Add comment · Share
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
0

Answer by giulio-pierucci · Feb 16, 2015 at 11:04 AM

Depends how do you want to link mouse to moviment.

You mey use transform.Rotate instead transform.localEulerAngles = newRot;

http://docs.unity3d.com/ScriptReference/Transform.Rotate.html

Comment
Add comment · Show 1 · Share
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 Avanak · Feb 16, 2015 at 06:04 PM 0
Share

This works with less lines of code, but it still inverts the camera movement when I "flip" the camera upside down.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

How to make my Camera Controller look at target 0 Answers

Unity - Dancing Ball World camera following and rotating system 1 Answer

Would anyone teach me how to create camera movement and look controls? 2 Answers

Cinemachine input axis camera movement,cinemachine input axis control with script 1 Answer

How to allow camera to complete an upside down rotation while using LookAt() 0 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