Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 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
1
Question by vagos21 · Mar 05, 2013 at 11:30 AM · transformparentchildfollow

how to do full child-parent transformation, without parenting?

Hello,

i've searched the forums and answers for this, and even though i found some close matters i couldn't find it, and it must all be down to math/geometry. i don't want to parent a gameobject to another one, because i want to avoid compound colliders creation (how i wish there was an option to turn them off!) so i must do the rotation and position of the child manually from its parent.

 function LateUpdate(){
     transform.position = parentPiece.transform.position + localPosition;
     transform.rotation = parentPiece.transform.rotation * localRotation;
 }

but i know i'm missing a bit in the position. because when i rotate the "parent" object the child does not follow in the place it should. it changes the position/rotation locally and it's not really behaving like a child.

so what do i have to add at the position part to make it look right? any equations for this? thank you!

Comment
Add comment · Show 6
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 Graham-Dunnett ♦♦ · Mar 05, 2013 at 11:39 AM 0
Share

GameObject hierarchies and compound colliders are totally unrelated. I don't quite understand your problem.

avatar image Steven-1 · Mar 05, 2013 at 12:38 PM 0
Share

oh wait, do you mean that the problem with the colliders is that when parenting, the child's collider will work as a collider for the parent?

avatar image vagos21 · Mar 05, 2013 at 12:43 PM 0
Share

Yes exactly this Steven and Graham, haven't you ever stumbled upon it? http://docs.unity3d.com/Documentation/Components/class-Rigidbody.html scroll down to compound colliders and you'll see what i'm talking about. i have parents and children with colliders, and all i end up with is a compound collider! so to avoid this i have to make my "children" game objects follow the "parent" without actually parenting them...

avatar image Steven-1 · Mar 05, 2013 at 12:47 PM 0
Share

well yeah, ofcourse we know about compound colliders, it just wasn't very clear first what the problem exactly was, since there isn't really much context

avatar image Graham-Dunnett ♦♦ · Mar 05, 2013 at 01:32 PM 0
Share

A compound collider is just a bunch of game objects in a hierarchy that have collider components attached. I don't think that hierarchies cause compound colliders to be created. If your hierarchy doesn't need colliders at every node, just delete the colliders from the game objects. (I have no idea how you are using physics, or what your hierarchy is, even. So this might not be possible in your case.)

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by Steven-1 · Mar 05, 2013 at 12:45 PM

Well what you're doing is definately wrong, but I don't immediately know The correct calculations.

But you could just use a workaround though: Create a new empty gameobject with identical transform to the wannabe child, make this the child instead. Then in a Late Update you just set the wannabee child's transformation equal to the new emptychild. Ofcourse, that's assuming you don't want to change the child's local position/rotation.

Edit: or just use Transform.TransformPoint()

transform.position = parentPiece.transform.TransformPoint(localPosition);

http://docs.unity3d.com/Documentation/ScriptReference/Transform.TransformPoint.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 vagos21 · Mar 05, 2013 at 03:22 PM 0
Share

great idea! actually i'll child the empty gameobjects to the parent and then set rotation and position of the indirect children almost like i did before

 function LateUpdate(){
     transform.position = parentGO.transform.position;
     transform.rotation = parentGO.transform.rotation;
 }
avatar image Steven-1 · Mar 05, 2013 at 04:19 PM 0
Share

That's exactly what I meant.

(my second solution is cleaner though)

avatar image sdgd · Dec 25, 2013 at 12:22 AM 0
Share

while searching for solution I came to this Q and digging more in to it I found this witch pointed me to Transform.RotateAround

anyway +1 to both Q && A

avatar image
0

Answer by thedetective456 · Sep 10, 2021 at 11:58 AM

Hey, I actually found a cool gut repo few hours ago : https://github.com/pointcache/Unity-3d-Constraints

Why not use default constraints? Cause they update somewhere after animator IK and late update in a loop called "PreLateUpdate", which is a problem for Animator IK. It forces you to use the "Animation Rigging".

Not anymore, have fun!

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

14 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

Related Questions

Make a simple tree 1 Answer

Set Position and Rotation with another GameObject as Pivot (Script) 0 Answers

Changing child's rotation changes parent's position 0 Answers

Properly Rotating Child Objects by Script 1 Answer

Make a GameObject child to a "Dragged Reference" GameObject doesn't work! 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