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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by thenachotech1113 · Oct 31, 2012 at 01:21 AM · transformrotatevar

i want an object rotate 45 degrees more than an other one

i am trying to make a spaceship controller. my idea was to use a cube make the spaceship move in the direction its aiming, and then the spaceship model to add details in this case, to tilt a bit while it is yawing. here is the code i`m using:

 var forceCube : Transform;
 
 var rotBufferZ = 0;
 var rotBufferY = 0;
 var rotBufferX = 0;
 var maxRot : int = 1;
 
 var roll = false;
 var rollDir = 0;
 var rollSpd = 1;
 
 function Start () {
 
 
 
 }
 
 function Update () {
 // this you`ll see why in a bit
 if (Input.GetKeyDown(KeyCode.A))rollDir = -1;
 else rollDir = 0;
 
 if (Input.GetKeyDown(KeyCode.D))rollDir = 1;
 else rollDir = 0;
 
 //here i use it to change the maximum rotation angle from 
 //positive to negative based on in what rotation i want him
 //to rotate  
 maxRot = maxRot * rollDir + forceCube.rotation;
 
 // if it can roll hell do so
 if (roll){
 transform.Rotate(rollDir * rollSpd, 0, 0);
 }
 
 //check if he has gotten to the max rotation to make him 
 //stop rotating 
 if (transform.rotation >= maxRot)roll = false;
 if (transform.rotation >= maxRot)roll = false;
 
 }


i guess a local variable would also work but i don`t know how to use them

thanks to all ho tried to help

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 Fattie · Oct 31, 2012 at 08:43 AM 0
Share

there is a huge intro to Quaternions, etc on unityGE$$anonymous$$S.com

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Montraydavis · Oct 31, 2012 at 02:44 AM

I don't even see anywhere in your script where you specify rotating 45 degrees more than the first object. Also, which axis are you trying to rotate it by 45 degrees??

 var Object1 : GameObject ;
 var Object2 : GameObject ;
 
 Object2.transform.Rotate ( Object1.transform.rotation.x + 45, Object1.transform.rotation.y + 45, Object1.transform.rotation.z + 45 ) ; // This rotates Object2 45 degrees more than Object 1 on axis XYZ .


But obviously, you will have to do a bit of work to make that smoothly rotate, but, that is the basis of what you "asked".

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 thenachotech1113 · Nov 12, 2012 at 05:10 PM 0
Share

yup, you are right

avatar image Montraydavis · Nov 13, 2012 at 12:49 PM 0
Share

Great. Glad this worked for you.

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

11 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

Related Questions

transform.localScale unexpected behavior after Rotate() 1 Answer

How to instantiate on custom rotation? 1 Answer

I could not be more lost (rotation script) 0 Answers

fixed rotation around object 1 Answer

How to lock the Z axis so my Enemy just flips on the Y axis 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