Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 adi_tya · Mar 28, 2017 at 05:02 PM · transformworldspacelocalspace

What is the difference between TransformDirection, TransformVector and TransformPoint since they all accept and return a Vector3 value.

I am a little confused about the these three functions as they accept and return a same kind of variable that is a Vector3. I would really like some passerby to leave me a few words of clarification on this topic. Thanks.

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

1 Reply

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

Answer by meat5000 · Mar 28, 2017 at 04:00 PM

Erm, yes, the Vector3 system in Unity (or in Mathematics for that matter) requires a little imagination.

Remember that a Vector consists of a Direction and a Distance.

Remember that Vectors are totally Commutable (They can be moved around and the same vectoral representation holds true).

In Mathematics we put a line over the Algebraic term to indicate its a Vector. In Unity we need to tell the compiler HOW to interpret the Vectoral information in the same way we tell it how to interpret Variables (int, float etc).

(1.0, 1.0, 1.0) is a point in space. Using a little imagination we can also consider that it can also represent a Vector IF WE ASSUME that the start of the Vector is at (0,0,0). This is the information that is missing and why it confuses you. Back to remembering that Vectors are commutable and suddenly you can see that this (1.0, 1.0, 1.0) can represent a vector of that direction and length anywhere in space. It still looks the same as a point in space but WE KNOW ITS NOT and we need to tell Unity how WE see it and would like to use it.

I presume TransformDirection returns a Unit Vector indicating a direction with no distance.

I presume TransformPoint returns a point in space.

I presume TransformVector returns a Vector which contains Direction and Distance provided you use the assumption that 0,0,0 is the starting point (dont worry its commutable).

This infomation will all look the same but you know its not.

Is any of this making sense? Feel like I'm rambling.

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 adi_tya · Apr 03, 2017 at 05:27 PM 0
Share

Hey, thanks a lot.You explained it really well.All of a sudden my doubts are clear.

avatar image MarshCZA · Apr 06, 2017 at 09:23 AM 3
Share

Just to add to this,

TransformDirection doesn't return a unit vector, it uses the inverse of the object's rotation to change a vector's direction into world space coordinates, keeping the length of the vector.

TransformVector does the same as TransformDirection but also changes the length of the vector depending on the scale (size) of the object.

TransformDirection is used to change the direction of local vectors to world vectors. Say for example, you had a force that you wanted to apply to an object and you always wanted the force to be in the object's upwards direction you would use

 transform.TransformDirection( new Vector3(0, 1, 0);

to get the force in world coordinates and then use AddForce. This is just an example and Unity has AddRelativeForce which will do this for you.

I have never found a need to use TransformVector as scaling up vectors when transfor$$anonymous$$g them has never been something I've had to do.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

transform.position is giving me local space 1 Answer

Add force forward to a ball using local coordinates doesn't work as I wanted 1 Answer

How do i move an object relative to another objects axis. 2 Answers

Instantiate prefab as child at a transform? (Javascript/Uniyscript) 2 Answers

Move camera along 2 axes in WorldSpace 2 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