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
1
Question by PaxForce · Feb 14, 2014 at 05:07 PM · transform.rotationtransform.rotate

transform.Rotate vs. transform.rotation = when use which?

Dear coding bros, I'm an absolute Unity noob. Could you be so kind and explain when it's better to use one and when the other of these two approaches? And what difference does it make? transform.rotation vs. transform.Rotate Thank you all. =========================

Thank you all for your replies, but I think I need to elaborate on my question: WHY would anybody use a ROTATION instead of ROTATE....and in WHAT cases EXACTLY. WHEN is it better to use ROTATION, when we already have ROTATE. Because I know that a gameObject can be rotated by it's transform using both. Give some brief examples of both cases, please.

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 Owen-Reynolds · Feb 15, 2014 at 03:42 PM 0
Share

There's no answer. You can Google and find lots of places where a person used one, but you or someone else would have used the other. That's the way program$$anonymous$$g works.

Rotate is a wrapper function -- a shortcut for a certain way of using rotation. Every program$$anonymous$$g environment has more shortcuts than any one person would ever want, and everyone always picks a few favorites.

An answerable question might be to ask how to rewrite a specific Rotate/rotation bit of code, using the other version.

4 Replies

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

Answer by Maui-M · Feb 14, 2014 at 05:18 PM

Rotation will set the objects rotation to that specified rotation. (As robertbu said, this should only be used by advanced users)

Rotate will take the current objects rotation and change it by the specified amount of rotation(Space.Self). (Useful for turning objects such as spinning or turning a car)

Rotate can also be used to rotate around other objects(Space.World). (Useful for rotating camera around player or orbiting planets.)

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 Owen-Reynolds · Feb 14, 2014 at 06:30 PM 0
Share

But setting rotation directly is often the obvious way. To snap an object "face up" use transform.rotation=Quaternion.identity;. To aim it right, use transform.rotation=Quaternion.Euler(0,90,0);.

avatar image
6

Answer by RedDevil · Feb 14, 2014 at 07:59 PM

Easy way of puting it is that transfrom.rotation is used to rotate at a specific angle an object,while transform.Rotate can cause the object to rotate continuously.And by the way there is one you missed transform.RotateAround that can make the object rotate around another object or an axis.

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
5

Answer by robertbu · Feb 14, 2014 at 05:16 PM

You are mixing apples and oranges here. Transform.rotation is a Quaternion...an non-intuitive 4D construct. Unless you have a firm understanding of Quaternions, you should not assign to it directly. You can use the Quaternion class to construct many rotations and assign them. There is a Transform.eulerAngles that can be assigned to that makes a better comparison.

The typical properties that make Transform.Rotate() special vs. other forms of rotation are:

  1. By default rotates around the local axes. Most other rotations default to using world axes.

  2. It is a delta rotation. It rotates an object by a certain number of degrees. Most other methods of rotating an object are by default are absolute rotations. That is an object is placed in a specific rotation.

Rotations can be complicated, and there are all sorts of ways of implementing various rotations.

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 Ujjwal_Rajput · Sep 28, 2020 at 01:56 PM

trasnform.rotation take Quaternion , i think you should ask for trasnform.eulerAngles vs transform.Rotate here i an example - i want to move my player as my camera is moving (using cinemachine freeLookCamera) for i take the value of X-Axis from the freeLookCamera component and put this value to the player

 void PlayerRotation() {
         float angleY = cinemachineFreeLook.m_XAxis.Value;
         Vector3 angle = new Vector3(0, 1, 0) * angleY;
         if (transform.eulerAngles.y != angleY) {
             //this.transform.Rotate(angle);
             transform.eulerAngles = angle;
         }
     }

i am calling this function in FixedUpdate() method when i use transform.Rotate player continuously rotating base on angle but when i use transform.eulerAngles it only rotate when the camera is rotated.

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

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

Related Questions

Issues with copying Y axisrotation of another object 2 Answers

Have Head Bone Rotate with Camera 2 Answers

Transform.Rotate() is rotating less than given rotation. What's going on? 4 Answers

Stopping transform.Rotate on an exact rotation value 1 Answer

Rotating an Object in Update Function 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