# Parent, Child and independent rotations

Hi there, I have an issue to do with a parent/child relationship and rotations. I need to be able to simultaneous lerp the parent objects rotation to a particular vector (currently I’m doing it with quaternion.lerp in a coroutine):

``````transform.rotation = Quaternion.Lerp (startingRotation, targetRotation, timer * m_speedOfRotation);
``````

…while at the same time, lerp the child objects rotation to a different vector. Obviously because of the parent/child relationship, the child is inheriting the rotation of the parent and screwing it all up. Is there a nice way that I can achieve this (I have to keep the parent/child relationship and I can’t temporarily decouple them).

Thanks so much for any help!

If I understand Quaternion’s then this should be put in the child’s rotation:

``````void Rotate ( Quaternion target) {
// Subtract the parents rotation from the current rotation
Quaternion actual = target * Quaternion.Inverse (transform.parent.rotation);

// Rotate to the actual target
Quaternion.Lerp (transform.rotation, actual, timer * m_speedOfRotation);
}
``````

Logic behind

So when an object is parented with another object, his transform is based of the parents. Meaning both position and rotation at 0 will be equal to the parents rotation. So if you want it to be parented and have a direction according to world direction, you need to subtract the parents rotation first.

If you don’t want the child to inherit the parents position, rotation and scale, it should not be a child in the first place. If you just want to inherit the position that can be achieved by a script.

As alternative you can store the childs current worldspace rotation in a seperate variable. Do not read back the actual child rotation. Just lerp your own variable to your desired rotation and set the child’s rotation each frame. Make sure you do this after the parent get rotated. As far as i know coroutines which yield null are run before Update. However if not you may want to use LateUpdate for the child adjustments.