- Home /
Passing the rotational component of a parent as a number
I have a solar system where each planet has a parent that controls its rotation around the sun. I am trying to get the rotational value of the parent so I can pass it as a number to another script controlling the rotation of the camera (when the planet is clicked I want the two to match).
What I'm asking is how do I read the rotational component of a parent object in C#. I've looked everywhere and I've found plenty regarding children, but very little on parents.
Answer by DaveA · Aug 01, 2011 at 08:34 PM
transform.parent.rotation, so to get angles, transform.parent.rotation.eulerAngles
Wow, I can't believe it was so easy... thanks a ton!
Another quick question, if I wanted to just get the x rotation component, would it be: transform.parent.rotation.eulerAngles.x?
Just tried it and answered my own question, thanks again.
Your answer
Follow this Question
Related Questions
Flip over an object (smooth transition) 3 Answers
Distribute terrain in zones 3 Answers
Destroying an object from its script. 1 Answer
Script to add script to all children 1 Answer