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
1
Question by Daniel G · Jul 11, 2013 at 04:00 AM · rotationjavascriptquaternion

Child Obj Ignoring Parents Rotation! Help

Hello! So i have a simple JAVAscript <(Only Please), turning my parent obj (diamond) and i want the 3D plane infront (Name of it) to NOT rotate. I want something like:

transform.rotation = Quaternion.identity;

Although this DOES Ignore Rotation it ALSO ignores position change which i DONT want. Plus it sets the rotation to 0,0,0 and i want it to automatically at start FIND the rotation of the obj the script is attached to (child that is) and store that, THEN set that as the rotation identity of that CHILD OBJ.

I want the CHILD obj to be able to Translate anywhere with the Parent, just NOT rotate!

Thanks so much for the Help, Daniel

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

Answer by clunk47 · Jul 11, 2013 at 04:04 AM

Get the startup rotation, then keep it at that in update.

 var defaultRot : Quaternion;

 function Start()
 {
     defaultRot = transform.rotation;
 }
 
 function Update()
 {
     if(transform.parent != null)
         transform.position = transform.parent.transform.position;
     transform.rotation = defaultRot;
 }
Comment
Add comment · Show 18 · 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 Daniel G · Jul 11, 2013 at 10:25 PM 1
Share

Thank you! @clunk47 I want to ALLOW Position change as well though! I want this child obj to be able to translate with the parent in any direction, just not rotate. You got an Idea?

Thanks, $$anonymous$$

avatar image clunk47 · Jul 11, 2013 at 10:57 PM 1
Share

Position should be automatically synced w/ the parent object. $$anonymous$$ake sure the object isn't losing its parent at runtime by checking if the parent is null (not available). Edited answer to show this.

avatar image clunk47 · Jul 12, 2013 at 12:03 AM 1
Share

$$anonymous$$y bad, I'll be more specific. Define your variable @ the top of your script.

 var defaultRot : Quaternion;
 
 function Start()
 {
     defaultRot = transform.rotation;
 }
 
 function Update()
 {
     transform.rotation = defaultRot;
 }

Edited Answer.

avatar image clunk47 · Jul 12, 2013 at 12:58 AM 1
Share

transform.position is a Vector3. transform.rotation is a Quaternion.

avatar image Daniel G · Jul 12, 2013 at 01:43 AM 2
Share

Haha! Thank you! :P Yes it DOES! Figured it all out!! You have educated me so well with this quaternion identity stuff thank you :P I found out it was all in my iTween animation, i changed the move to to $$anonymous$$ove Add!! This added to what ever the parent was and Thus kept the obj with it and happy :D

Show more comments

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

15 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

Related Questions

Multiple Cars not working 1 Answer

Gun Rotation 2 Answers

How to make a animation rotation js.script? 2 Answers

Finding A Rigidbody's Rotation Speed And Direction 2 Answers

Lerp with raycast hit.normal? 2 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