Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 SecretAgentMango · Mar 23, 2021 at 02:06 AM · 2dpositioningparent-child

Why do my child object and parent object have the exact same absolute position?

I am trying to put a sprite of sword within an empty game object so that way I can rotate the sprite about the hilt. But, for whatever reason, as soon as a I make my sword a child of the empty object, both their positions immediately become the exact same. It's clear to see in this GIF I made of the issue. Why is this happening?

GIF: https://imgur.com/a/yQeagjw

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

4 Replies

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

Answer by jackmw94 · Mar 23, 2021 at 09:56 AM

Your gizmo handles are set to "center" rather than "pivot", click the button that says center, next to where it says local just above your scene view to get the behaviour you're expecting :)

See gizmo handles position toggles for more info: https://docs.unity3d.com/Manual/PositioningGameObjects.html

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 SecretAgentMango · Mar 24, 2021 at 01:22 AM 0
Share

Yep, that was it exactly. Thank you!

avatar image
0

Answer by Draxhtar · Mar 23, 2021 at 10:03 AM

@SecretAgentMango They don't become the exact same,

When you make the sword object a child of the empty game object:

Transform component starts using the local position of the empty object Instead of the world position.

So normal objects uses world position, child objects uses the local position of the parent object of itself.

When a child object uses the local position of the parent object, it's position gets calculated related to parent object's position. It assumes the parent object as the 0, 0, 0 origin and calculates child object's position relative to that.


Example:

Let's say there are 2 objects,

Object A's position: 5, 0, 0

Object B's position: 8, 0, 0

If we make the Object B a child of the Object A, let's calculate what happens:

Object A's position stays the same in world position: 5, 0, 0

Object B's position becomes 3, 0, 0 because it assumes the 5, 0, 0 position as 0, 0, 0.

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 jackmw94 · Mar 23, 2021 at 10:52 AM 0
Share

Everything you're saying is spot on but I don't think that was the problem OP was facing, you can see in the gif that their parent object's gizmo assumes the position of its child - the "center" gizmo positioning setting causes this as it means the gizmo gets placed at the average position of its children.

avatar image
0

Answer by Ermiq · Mar 23, 2021 at 12:12 PM

Either what @jackmw94 said, or it's the animator is messing things up.
The animator component could modify transform positions (and rotations). I had a lot of weird things happening when I've been trying to figure out how to use animations and animator components in Unity. And this behavior looks pretty much like one of the issues I've encountered. Try to disable the animator and see what will happen then.

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 J_Ripley · Nov 27, 2021 at 05:05 PM

I was looking at your answer @Draxhtar as I had the same question. In a video I am Watching, Jason created an empty GameObject he titled Player. Then made the soldier to be a child of Player so should one want to switch out the characters, not having reset all the prefabs and etc. I also noticed the position of the parent and the soldier was not in the same exact spot.

Here is the part that throws me. In the video, Jason added Character Controller to the Player and not the child or soldier. The video showed the lines (similar to a collider, but it was actually on the soldier where when I followed suit it was not using the Parent that was renamed Player. Now when I removed the Character Controller from the Parent or Player and add it to the child or soldier, the lines like a collider does show on the soldier itself just like the video. Was that a mistake on the video itself???

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

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

Related Questions

Lights that ignore position.z of GameObject 0 Answers

Make player automatically move up on a tile 1 Answer

Two quads, same position, which one is seen ahead? 1 Answer

Parent and Child looking at mouse 0 Answers

Assets/Scripts/PlayerController.cs(32,49): error CS0126: An object of a type convertible to `float' is required for the return statement 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