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 Psychel · Feb 06, 2012 at 02:12 PM · rotationtransform.rotationinput.getkeytilting

Question about positive and negative imput values.

Hello !

So i was reading the documentation a while, and finnaly got this to work verry nicely ! But now im seriously bugged about something.

This part of the code makes the "ship" rotate to the left smoothly. This works perfectly.

 //if you press A key ship will rotate Z +  axis
      if (Input.GetKey (KeyCode.A))
         { 
             playerShip = Quaternion.Euler (0, 0, tiltAroundZ);
 
             //Dampens twoards the rotation
             transform.rotation = Quaternion.Slerp(transform.rotation, playerShip, Time.deltaTime * smooth);
 
             print ("Horizontal Positive key A was Pressed");
 
         }
 


What im wondering is why the code makes it rotate to the right if i change the keycode to D key. With the same values and exactly the same code as above ?

Comment
Add comment · Show 2
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 tingham · Feb 06, 2012 at 04:31 PM 0
Share

You need to clarify the actual question here. $$anonymous$$ost folks are more than happy to help but nobody want's to try and decode a question from a couple of different assumptions.

avatar image Psychel · Feb 06, 2012 at 05:57 PM 0
Share

Alright ! updated. sorry it was a mess, i hope the question is understandable atm.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by DavidDebnar · Feb 06, 2012 at 06:37 PM

You have it there! First you have //if you press A key ship will rotate Z + axis and than //if you press A key ship will rotate Z - axis. So in this case, raw A value returns 1 and raw D input value -1 so it rotates to the opposite direction! And the tilt value for horizontal rotation is negative so you will get positive tilt value for D and negative for A if I am sure. Go to project settings-input in unity and check the positive and negative value. AND you were wondering why does the ship tilt to right when you change the key code to D, well that's because you use the keycody only in the if statement and use axis in the tilt variable.

I am writing the code atm.

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 DavidDebnar · Feb 10, 2012 at 07:14 PM 0
Share

would you $$anonymous$$d clicking the tick under the thumbs up button?

avatar image
0

Answer by Psychel · Feb 06, 2012 at 08:33 PM

Owh ! then i understand, i was a bit baffled that it returned - value and + value by its self. i thought i had to write a new if statement for each + and minus value. thanks for clearing that up !

Yeah the tilting i knew already why since that was the code i was writing, it was basicaly why did it tilt without me writing a positive value for the D.

You can copypaste the code and drag it onto a prefab with a player tag and it will auto work.

Thanks for clearing the part about negative and positive values given by the keycode. You were right about the positive and negative values given by the keys. it was autosetup. i never knew that so thanks again, i learned something new trough this.

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

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

6 People are following this question.

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

Related Questions

Have Head Bone Rotate with Camera 2 Answers

How to make a gameobject have a rotation constraint? 1 Answer

How can I pitch and roll a circular platform without releasing vertical/horizontal input? 1 Answer

Adding Rotation to a Gameobject 1 Answer

Instantiate facing world zero on Y axis? 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