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 D3velop · Jun 28, 2015 at 08:07 PM · rotationphysicstransformparentchild

Separate child rotation

Hi,

I'm moving an object using AddForce in a particular direction and rotating the transform using this:

 var mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

 Quaternion rot = Quaternion.LookRotation(thisTransform.position - mousePosition, Vector3.forward);

 transform.rotation = rot;
 transform.eulerAngles = new Vector3(0, 0, thisTransform.eulerAngles.z);

My object has a child object which moves with it. However, I'd like the child object to be in the same position as the parent object but have a different rotation that I can move separately. Is there a way to do this?

One idea I had was removing the child completely but I'm concerned that as these are both moved via physics, they could separate their positions.

Thanks for any help

Comment
Add comment · Show 2
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 maccabbe · Jun 28, 2015 at 08:15 PM 0
Share

Seems like it would be easiest to make both objects children of a new object that controls their position while the children each control their own rotation.

avatar image D3velop · Jun 28, 2015 at 08:34 PM 0
Share

Apologies if I'm not understanding but would there not be the same issue present except with the parent object ins$$anonymous$$d?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Inok · Jun 28, 2015 at 08:27 PM

you can detach "children" and translate its position to position of "ex parent" by simply write few line of code:

 Transform Parent_Tr;
 Transform Child_Tr;
     
     void Update()
     {
       Child_Tr.position = Parent_Tr.position;
     }

But this work only if "ex children" not have own rigidbody.

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 D3velop · Jun 28, 2015 at 08:32 PM 0
Share

Sorry, they both have rigid bodies but thanks for your reply.

avatar image Inok · Jun 29, 2015 at 04:46 AM 0
Share

You then can connect them by configurable joint, its most advanced.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Moving child transform also moves parent rigidbody 0 Answers

Parent transform not following child transform 0 Answers

Raycasting from child weird behaviour 2 Answers

Camera follow ball along cylinder 1 Answer

Changing child's rotation changes parent's position 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