Child of a gameobject lookAt only around Y-axys

I have 3d scene with 3 objects (player, main object and child of main object), I need to make both objects always lookAt the player, by rotate them only around Y-axys… im total beginner in unity and hope there is no abvious solution :slight_smile:

[154104-снимок.png|154104]

on main object i have script and this work fine, but when i attach same script to child its looks weird…

void Start()
{
    cameraPlayer = GameObject.FindGameObjectWithTag("Player Camera");
}
void Update()
{        
    Vector3 directionToPlayer = cameraPlayer.transform.position - transform.position;
    Quaternion rotateAt = Quaternion.LookRotation(directionToPlayer);
    Vector3 rotation = rotateAt.eulerAngles;
    platformCanvasRotator.rotation = Quaternion.Euler(0f, rotation.y, 0f);
}

}

Try the following;

void Update()
{        
    Vector3 directionToPlayer = cameraPlayer.transform.position - transform.position;
    directionToPlayer.y = 0f;
    transform.rotation = Quaternion.LookRotation (directionToPlayer.normalized);
}