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 /
avatar image
0
Question by drex · Sep 05, 2011 at 11:42 PM · rotationfirst-personmouse look

Mouse Look Controller that can rotate on the Z axis

Heya all.

I'm looking for a code that will let me rotate my first person controller on the Z axis. I'm making a game where gravity changes and the character needs to be able to rotate to be on his feet again instead of hitting his head on the roof which has now become the floor.

I've already gotten the movement and jumping down, but the default mouse look script refuses to let me rotate on the Z axis no matter what. I looked at it's code, it's a bit complex for me. I get that it's trying to keep me straight up. That's fine, I like that part, I just want a way to disable that for a bit to flip the character and turn it back on after.

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
0

Answer by nasapc123 · Sep 06, 2011 at 04:32 AM

hey is this roughly what you want? change the block which reads:

else if (axes == RotationAxes.MouseX){

         transform.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX, 0);

     }

into

else if (axes == RotationAxes.MouseX){

         transform.Rotate(0, 0, Input.GetAxis("Mouse X") * sensitivityX);

     }

is that what you want?

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 drex · Sep 08, 2011 at 01:35 AM 0
Share

That wasn't quite what I was looking for. Thanks for the help though.

I eventually figured it out after lots of trial and error. The line that was giving me all the trouble was the "originalRotation" code that is built into the $$anonymous$$ouse Look script. Original rotation starts with 0,0,0,1 and tries to never change. So I just made a code that would change the Z on that on demand.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Turret on Tank rotating fine until I'm not flat on ground 1 Answer

Third-person Mouse Look Script? 0 Answers

I want the camera, which is following my spaceship, to rotate to wherever the cursor is looking 0 Answers

Player rotation in Unity 5 0 Answers

z-axis Rotation 2 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