Child object is not rotating with parent?

So I have an enemy that follows the player, with a child object that is initially aligned exactly with the parent, that I want to constantly oscillate back and forth in the parent’s forward 180 degree arc.

I have it working, but its using world space no matter what I try. Here’s how I’m doing it:

function Update(){

    if(reverse){
       transform.Rotate(-transform.up*Time.deltaTime*30.0, Space.Self);
       if(transform.rotation.eulerAngles.y < 90.0)
         reverse = false;
    }
    else{
       transform.Rotate(transform.up*Time.deltaTime*30.0, Space.Self);
       if(transform.rotation.eulerAngles.y > 270.0)
         reverse = true;
    }

}

I’ve tried a multitude of combinations, between changing transform.up to transform.parent.up, Space.World, etc., to no avail :frowning:

Cross-post: Child object is not rotating with parent - Questions & Answers - Unity Discussions

Ugh, solved! Nevermind :slight_smile:

For some reason I kept thinking transform.rotation.eulerAngles would be giving me the local by default, like transform.forward/transform.right, etc…, forgot about .localRotation! And I was wondering why when I was echoing the eulerAngles my values were completely different than the inspector!