• 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 ninjaoboy · Jul 26, 2011 at 08:22 PM · positionvector3parentchild

How to move a child to the world vector 3 position?

I have something that is a child of the player and i want it to still be the child because it will make my game neater and i need it to stay at the global 0 position regardless of where the player is.

UPDATE**** I feel so stupid i thank you guys for your help... the problem was i put it on a script that is most of the time disabled... wow.... well thanks for your help anyway.

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
2
Best Answer

Answer by almo · Jul 26, 2011 at 08:27 PM

Doesn't

childobj.transform.position = Vector3.zero

Do this? The docs say transform.position gives the world coordinates of the object.

http://unity3d.com/support/documentation/ScriptReference/Transform-position.html

Comment
Add comment · Show 3 · 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 ninjaoboy · Jul 26, 2011 at 08:30 PM 0
Share

i tried that already doesn't work i will just have to have a confusing mess in my assets.

avatar image Scribe · Jul 26, 2011 at 08:55 PM 0
Share

I think what Almo wrote should work, where in your script have you put this. put it in your function Update () at the start with no if's so that at every frame it resets to vector3.zero

avatar image ChristmasEve · Jan 01, 2021 at 07:25 PM 0
Share

I know this post is old but I'm using 2020.1.17f1 and his actually doesn't work. I have no idea if there has been a change. This is insane. I absolutely cannot set the world position of a child or do it the other way - instantiate an object at a world position and then try to parent it. The first thing I tried is this - parent it and then set its transform.position. When that failed, I tried transform.SetParent() with a true for keepworldposition. I've tried TransformPoint. I've tried a half dozen other things besides this too, and the object keeps moving on me. One thing to note, the parent I'm trying to attach it to is a descendant of a huge twisted mess of a tree with many rotations and scales. For the life of me, I cannot set the absolute position.

avatar image
2

Answer by flaviusxvii · Jul 26, 2011 at 09:02 PM

I appreciate that you think you game structure will be 'neater' but using the Transform parent child relationship for organization that doesn't mirror what the Transform actually represents is folly.

If you TRULY want to do this.. then you need a new script called something like AlwaysAtOrigin and in its Update function just have the line "transform.position = Vector3.zero;"

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Make a simple tree 1 Answer

Simulate Child Parent Relationship (parent constraint) 2 Answers

How make an object child of other object without changing the child position? 0 Answers

camera and positiong problems 1 Answer

how to stop child object from twitching? 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