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 newagenoah · Jun 15, 2013 at 05:59 PM · javascript

How to rotate 90 degrees

 function Update() {
 
 if(Input.GetKeyDown("D")) {
      transform.rotate += 90
 }

I'm not actually in unity right now but I just wanted to know if it would look something like this. I'm working on a project for a game for the blind.

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 newagenoah · Jun 15, 2013 at 05:07 PM 0
Share

Sorry I forgot to name the variable for rotation.

4 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by pickle chips · Jun 16, 2013 at 01:04 PM

It depends what exactly you want it to do. If you just want it snap to 90 degrees, with no smoothing, then this is what your code should look like

 if (Input.GetKeyDown(KeyCode.D)) {
     transform.Rotate(0, 90, 0);    
 }
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 newagenoah · Jun 17, 2013 at 07:26 PM 0
Share

Should I do $$anonymous$$eyCode.D or "D"

avatar image pickle chips · Jun 17, 2013 at 07:37 PM 0
Share

It depends. $$anonymous$$eycode can be used if The game is only going to be using a computer (with a keyboard), and you don't want the user to configure the controls them self. It's just simpler since you don't need to use the input manager.

But, if you do want it to be able to use something other than a keyboard, or you want the user to be able to change the controls, then use "D", with the input manager.

I just used $$anonymous$$eyCode.D out of habit, but "D" might be a better option.

avatar image
0

Answer by Graham-Dunnett · Jun 15, 2013 at 08:50 PM

http://docs.unity3d.com/Documentation/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 newagenoah · Jun 15, 2013 at 10:52 PM 0
Share

I've already seen that but I wanted to know if I'm doing it right.

avatar image
0

Answer by Kirbyrawr · Jun 16, 2013 at 12:24 PM

You are not specifying the Vector or the axis... So what you want to rotate?

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 Griffo · Jun 16, 2013 at 12:51 PM

Try this X,Y,Z

 if (Input.GetKeyDown ("3")){
      transform.Rotate(Vector3(0,90,0));
 }
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 create3dgames · Jun 17, 2013 at 07:42 PM 0
Share

You could just do Vector3.right

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

19 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

audio not playing when i destroy gameobject or setactive to false,audio not playing when i destroy gameobject or setactive into false 1 Answer

A node in a childnode? 1 Answer

Texture2d.Readpixel slow down performance while stand-alone exe is minimize 0 Answers

Fade in Fade out in unity 1 Answer

Hide the ImageTraget in Real world 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