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 /
avatar image
0
Question by WaterMinecraft · Oct 15, 2013 at 01:08 AM · movement scriptmouselookscript loading

Mouse Script Reversed (y and x axis)

Hey, I've been following some tutorials, and I finished the mouse looking script. When I run the script, the x and y axis are sort of reversed. Like when I slide left and right on with my mouse it looks up and down, and when I slide up and down, it looks left and right...? Can anyone help?

pragma strict var lookSensitivity : float = 5f; var xRotation : float; var yRotation : float; var currentXRotation : float; var currentYRotation : float; var xRotationV : float; var yRotationV : float; var lookSmoothDamp : float = 0.1; function Update () { xRotation -= Input.GetAxis("Mouse X") * lookSensitivity; yRotation += Input.GetAxis("Mouse Y") * lookSensitivity; xRotation = Mathf.Clamp(xRotation, -90, 90); currentXRotation = Mathf.SmoothDamp(currentXRotation, xRotation, xRotationV, lookSmoothDamp); currentYRotation = Mathf.SmoothDamp(currentYRotation, yRotation, yRotationV, lookSmoothDamp); transform.rotation = Quaternion.Euler(currentXRotation, currentYRotation, 0); }

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by robertbu · Oct 15, 2013 at 01:10 AM

This will be true for almost any script that uses Input.GetAxis(). That is, a user expects horizontal mouse movements will rotate your object around it 'Y' axis, and vertical movement will rotate something around the 'X' axis. Reverse your assignment to currentXRotation and currentYRotation.

Comment
Add comment · Show 2 · 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 WaterMinecraft · Oct 15, 2013 at 01:14 AM 0
Share

Thanks, but how exactly do I do that? Haha Sorry! I'm used to Java, not JavaScript.

avatar image robertbu · Oct 15, 2013 at 03:31 PM 1
Share

Just reverse your inputs:

 transform.rotation = Quaternion.Euler(currentYRotation, currentXRotation, 0);

You may have to negate one or the other.

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

14 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to use Configurable Joints and DragRigidBody Script with a door 0 Answers

Gun Sway Script glitching 0 Answers

Acceleration script 2 Answers

How can I make my character move only in one axis or direction at a time? 0 Answers

Footstep Script (NullReferenceException: Object reference not set to an instance of an object) 1 Answer


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