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 rednax20 · Dec 19, 2013 at 03:23 AM · rotationtransformrotate

I could not be more lost (rotation script)

I am trying to make a script that would rotate a cylinder on button push but still restrict movement. I basically want it to move from 0 to 90 degrees freely but stop it from moving any farther.

The real problem is i am trying to do the exact same thing with another cylinder with different keys in a different direction(270 - 360).

Oh, the problems I've had. I have tried so many things to fix my problem, i don't even no what problem is what anymore.

so after 2 hours of sheer frustration i decided to ask for some help.

 if(direction == 1){//dont worry about this
         if((Input.GetKey(keys[0])||Input.GetKey(keys[2]) &&   transform.rotation.eulerAngles.x < 340)){// if figure that restraining it a 340(close enough to 360)
 // will stop it from annoyingly switching back over to zero rotation

         
             transform.Rotate(4,0,0);
     
         }    
     
         if( (Input.GetKey(keys[1]) ||Input.GetKey(keys[3])) && transform.rotation.eulerAngles.x > 270){
     //by the way keys[] is an array that holds string values, that all works great
         transform.Rotate(-4,0,0);
         }
         }else{
 //again don't worry about the else, t just separates the cylinders from each other, so i know which way to move it
         if((Input.GetKey(keys[0])||Input.GetKey(keys[2]) )&& transform.rotation.eulerAngles.x < 90){// this would be the other cylinder
         
             transform.Rotate(4,0,0);
     
         }    
     
         if( (Input.GetKey(keys[1]) ||Input.GetKey(keys[3]))  &&transform.rotation.eulerAngles.x >5 ){
     
         transform.Rotate(-4,0,0);
         }        
         
         
         }

Just incase i forgot to mention, the problem is that the cylinder fails to stop moving. thank you for your time

have a Quishtay™ Day

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 KellyThomas · Dec 19, 2013 at 03:58 AM 0
Share

I suggest simplifying things to start with.

First get it working with one object.

Then look at refactoring the movement code into a separate function that can be applied to each object.

0 Replies

· Add your reply
  • Sort: 

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

how to tilt boat on turning 2 Answers

Rotation Jumping values (0 to 180) 1 Answer

Setting rotation of game object relative to ground does not work 1 Answer

transform.Rotate will not work 1 Answer

Moving Camera on player stop then move and rotate to separate point? 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