Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by alqaadi · Nov 13, 2015 at 01:56 PM · rotationparentchild object

parent and child

1: my first problem is : i get exactly 44.9901 with me using this script

if(transform.eulerAngles.z==135) { transform.rotation = Quaternion.Euler(transform.eulerAngles.x,transform.eulerAngles.y,45); } i dont know why it's 2d , there is no rigidbody nothing else except 2dcollider.

2: second problem is child and his parent , i had written this code to stop the child moving from the start pos while parent is constantly moving.

Vector2 trS = new Vector2(0,0);

child.transform.position = trS-parent.transform.position;

let me explain this code before you ask the meaning.

for example parent.trans.pos.x = 0 and child.trans.pos.x=0

if parent.tans.pos.x starts to change and become 1 unit for the child will stay 0 relative to the world but relative to his parent his pos.x=-1,, but with my script it seem that they're both running from trS(0,0)

3: the third one is the wierdest but i will post it on the first comment. if you know the solution please make it quick i'm stuck until the answer arrives thank.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Tyche10 · Nov 13, 2015 at 03:36 PM

I think your second problem is because you are changing transform.position (position in world space) instead of transform.localPosition (position relative to parent).

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 alqaadi · Nov 14, 2015 at 11:51 AM 0
Share

it's working thanks i will post the third one

avatar image alqaadi · Nov 15, 2015 at 12:02 PM 0
Share

if child.pos.x=0(relative to parent) && parent.pos.x=0; if parent.pos.x=7 and child.pos.x(relative to world) stay = 0 then what would relative parent !? = -7 right but $$anonymous$$e becomes exactly -6.64 why?

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

Child always on parent top to get the number of dice 0 Answers

How do I find the rotation of a game object in relation to its grandparent 1 Answer

Changing parent at runtime rotates object. 0 Answers

How does child's rigid body affect parent's rigidbody? 1 Answer

Child object not rotating as parent 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