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
2
Question by C___ · Jun 22, 2015 at 10:51 AM · rotationphysicsrigidbodytransformposition

how to CORRECTLY position and rotate a gameobject in unity

How to correctly position and rotate a gameobject taking into consideration the different methods available?

Can anyone diminish the confusion by giving an explanation of what each of the following functions does and in what context should it be used (best practices, etc.)?

- Transform.position/localPosition

"The position of the transform in world space./Position of the transform relative to the parent transform."

- Transform.rotation/localRotation

"The rotation of the transform in world space stored as a Quaternion./The rotation of the transform relative to the parent transform's rotation."

"Unity stores rotations as Quaternions internally. To rotate an object, use Transform.Rotate. Use Transform.eulerAngles for setting the rotation as euler angles." -what does this mean? when do i use these 3 ways of rotating a gameobject?

- Transform.Rotate

"Applies a rotation of eulerAngles.z degrees around the z axis, eulerAngles.x degrees around the x axis, and eulerAngles.y degrees around the y axis (in that order)."-why would i use Transform.Rotate and not Transform.rotation/localRotation?

- Transform.Translate

"Moves the transform in the direction and distance of translation."-why would i use Transform.Translate and not Transform.position/localPosition?

- Transform.eulerAngles

"Only use this variable to read and set the angles to absolute values. Don't increment them, as it will fail when the angle exceeds 360 degrees."

- Rigidbody.position

"Get and set the position of a Rigidbody using the physics engine."

"Use this if you want to teleport a rigidbody from one position to another, with no intermediate positions being rendered."

"The transform will be updated after the next physics simulation step."

- Rigidbody.rotation

"Get and set the rotation of a Rigidbody using the physics engine."

"Use this if you want to teleport a rigidbody from one rotation to another, with no intermediate positions being rendered."

"The transform will be updated after the next physics simulation step."

- Rigidbody.MovePosition

"Use this if you want to continuously move a rigidbody in each FixedUpdate, which takes interpolation into account."

- Rigidbody.MoveRotation

"Use this if you want to continuously rotate a rigidbody in each FixedUpdate, which takes interpolation into account."

- Rigidbody.AddForce

"Adds a force to the rigidbody."-used when?

- Rigidbody.AddTorque

"Adds a torque to the rigidbody."-used when?

The only big difference i know between these is that you want to use Rigidbody functions for physics game objects, that are not kinematic. other than that, they seem to achieve the same result.

Other comments about this subject are appreciated.

Links

http://docs.unity3d.com/ScriptReference/Transform.html
http://docs.unity3d.com/ScriptReference/Rigidbody.html

Comment
Add comment
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

2 Replies

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

Answer by Hellium · Jun 22, 2015 at 11:27 AM

I think that the documentation is quite clear about this :

  • Transform.position :

    Places your object in a specific point in the world space (regardless of the position of its parent). Places the object instantly, regardless to its previous position => Absolute position in world space.

  • Transform.localPosition :

    Places your object in a specific point considering the position of its parent (the position of the parent is the origin of the "sub-space" of your object. Places the object instantly, regardless to its previous position => Absolute position in parent space.

  • Transform.rotation:

    Set the rotation of your object in a specific way (set by Quaternion) in the world space (regardless of the rotation of its parent). Set the rotation of the object instantly, regardless to its previous rotation => Absolute rotation in world space.

  • Transform.localRotation :

    Set the rotation of your object in a specific way (set by Quaternion) considering the rotation of its parent (the rotation of the parent is (0, 0, 0, 0) for you object) => Absolute rotation in parent space. Set the rotation of the object instantly, regardless to its previous rotation.

  • Transform.eulerAngles

    Same as Transform.rotation but with euler angles (pitch, yaw, roll) to be easier to manipulate for humans.

  • Transform.Translate

    Makes your object move considering its previous position (relative) and in its own space (unless you specify the relativeTo argument to Space.World). Use it if you do not know the position of if the final position doesn't matter => Relative position in self / world space.

  • Transform.Rotate

    Makes your object turn considering its previous rotation (relative) and in its own space (unless you specify the relativeTo argument to Space.World). Use it if you do not know the rotation of your object or if the final rotation doesn't matter (you just want you object to turn) => Relative position in self / world space.

Rigidbody functions are based on physics, adding force to an object will "propel" your object in a direction for instance. As if you shoot in a soccer ball with your foot. You don't have to calculate the position of your ball each FixedUpdate, the physics engine will do it for you.

Comment
Add comment · Show 7 · 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 C___ · Jun 22, 2015 at 12:09 PM 0
Share

so AddForce/AddTorque is not meant to be used when wanting to position/rotate a rigidbody from point A to a fixed point B?

avatar image Hellium · Jun 22, 2015 at 12:19 PM 1
Share

Indeed !

I have never used the AddTorque function though.

I think that the other functions of the Rigidbody class are used if you have custom physics laws and you want to calculate all by yourslef.

You must also know that moving a transform will also move its rigidbody.

avatar image C___ · Jun 22, 2015 at 06:57 PM 0
Share

thanks for the answer. much clearer now.

avatar image Hellium · Jun 23, 2015 at 11:25 AM 1
Share

I see what you mean, but unfortunately, the answer of tis question is out of my knowledge. I think you should not bother yourself with this question and use the way your prefere ! ;)

avatar image Hellium · Jun 25, 2015 at 12:50 PM 1
Share

I have realised something @C___ about using Translate ins$$anonymous$$d of the position/localPosition. I have made a mistake in my answer, I will correct it now :

When you use Translate ins$$anonymous$$d of position/local position, you are manipulating the object in its OWN space (unless you specify the relativeTo argument to Space.World)

Show more comments
avatar image
0

Answer by talhaijaz · Jun 27, 2017 at 08:58 AM

in my case transform .position works as transform .local position it depends on previous position of object how do i resolve it? @Hellium

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Get direction of moving sphere? 1 Answer

How to always face player relative to player's rotation and how do I use TransformDirection to move a player regardless of Y-rotation? 0 Answers

Transform.Position vs Rigidbody.Position 1 Answer

How to make an object(cylinder) always at the center of an object(Terrain)? 0 Answers

How to know if rotating ball is rotating towards or away from camera. 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