Get Parent to rotate like child but only in Y axis

I am trying to get the parent object to rotate like the child only in the y axis, I can’t seem to figure it out. The parent is moving forward in the Z axis and the child should control its rotation.

There are no rigidbody’s in the objects and i tried adding and locking in the editor but it didn’t work.

How do I lock it so it only rotates in the y axis?

I have tried Quaternion.LookRotation but I find it is two times too slow and sometimes my camera is facing forward while my object is moving backwards. I need the parent and child to face the same way

I have tried this code but when I rotate the child the parent starts spinning out of control in all the axis’.

void Start () {
theChild = transform.GetChild (0);
theParent = transform;
}

void FixedUpdate () {
theParent.rotation = theChild.rotation;
}

I have also tried this but it doesn’t seem to work at all

theParent.rotation = Quaternion.Euler (newVector3 (0, theChild.rotation.y, 0));

This code is for a google cardboard VR app so the person walks forward the direction they are facing

The parent is going to rotate according to the change in the Y axis but then the child is parented so it too moves when the parent moves so it moves even more so it continues to accelerte and so your parent starts to spin out of control.

how do i stop that then?

Use the ‘target’ option of the CardboardHead to point to a game object other than the parent (grandparent, perhaps).

Or another way to do this is to not rotate the parent but to just move it according to the direction in world space that the user is looking:

Vector3 fwd = Camera.main.transform.forward;
fwd.z = 0;
parent.transform.position += speed * fwd.normalized;