lookAt on Y axis only

i know this question has been asked before but i didn’t work in the script i’m using, i need the transform variable “turret” to look at the transform variable “target” only on the Y axis based around the current script part i’m using:

turret.transform.LookAt(target);

thanks :slight_smile:

maybe not the most efficient, but a working solution:

Vector3 eulerBefore = turret.transform.eulerAngles; // or localEulerAngles, dependent on your needs
turret.transform.LookAt(target);
eulerBefore.y = turret.transform.eulerAngles.y;
turret.transform.eulerAngles = eulerBefore;