Get euler angle from parent component

Hi Guys

I was wondering if it was possible to get the euler z angle of a parent object. Ideally I would like to rotate an object where its turn speed is a function (sine function) of the euler angle of its parent. The parent will also rotate independently.

Any help would be greatly appreciated.

Sure, transform.parent.rotation.eulerAngles… but maybe there’s more to what you’re trying to do than I understand?

You don’t need .rotation.
http://docs.unity3d.com/ScriptReference/Transform-eulerAngles.html

Good catch!

Hi

Thanks for the quick reply.

I’m not doing anything complex at the moment I just want to test a method in principle.

I have the parent cube rotating around the z axis at a constant speed.
Now I have a second cube rotating around its own z axis again but I want it speed to be = parent speed * sin(z euler angle of parent).

i tried transform.parent.eulerangles.z but its always 0 even when the parent is rotating about its z axis.

Well, something’s funny there. Try printing out transform.parent.gameObject.name. I think maybe it isn’t what you think it is.