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 Aladine · Sep 03, 2013 at 10:27 PM · positionchild

Position as a child

Hello everyone, i want to know the difference between the object position when it's "free" and when it's a child of another object, i was trying to make this but it didn't actually work,

  • have an object with a Y position (as a child)is equal to 2.5 -in some point of the game i want to to go to a Y position equal to 0 -then in another point i want it to get back to 2.5 when i tried to do it, the object did go to 2.5 but in reality i didn't want it to be there, the position am seeking is 0.4, cause that is the real Y position when i "un-child" the object, i tried my code with the 0.4 and it worked

the question is, how to work with the "2.5" value but make the script understand it as a 0.4

thank you

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 flaviusxvii · Sep 03, 2013 at 10:30 PM 0
Share

transform.position is always relative to WORLD SPAC$$anonymous$$ transform.localPosition is the position of the transform relative to it's immediate parent.

1 Reply

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

Answer by hellaeon · Sep 03, 2013 at 10:56 PM

You have to remember relative movement. If you yourself are a parent object and your carrying a phone, if you move the phone around it won't change your position in the world if you stand still.

With that idea, to the phone you are it's world, you are it's 0,0,0.

What you see in the phones transform position are its coordinates starting from this 0,0,0 (you)

It is important to understand this by doing a few tests.

 1) create a parent object at (0,0,0)
 2) add a child object
 3) set the child transform.position to (0,0,0)
 3) move the child to (5,0,0)
 4) now move the parent, the child moves with it, but the child transform.position won't change.

the child's position is shown in relation to the parent, which is the center of its world coordinate system To get the child's position in the main world coordinate system, you might want to try transform.transformPoint

You just have to remember when dealing with transform space, your parent is your child's (0,0,0) I would suggest doing a google on local space v world space.

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 Aladine · Sep 04, 2013 at 09:25 PM 0
Share

@flaviusxvii thanx for the quick reply @hellseon thank you for the explanation, it helped a lot

avatar image hellaeon · Sep 04, 2013 at 09:46 PM 0
Share

Too easy mate, happy to help!

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

18 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

Related Questions

Transform child object over time and then destroy it. 1 Answer

Children Objects move weird 1 Answer

why is transform.position giving me local location?(c#) 0 Answers

How can I make a First Person Character Controller a child of a moving platform without it affecting the rotation of the Character Controller. 1 Answer

Get child position in world space 4 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