Transform.LookAt but only in 2 directions ?

Hi,

How can I do to get my “lookat” look at my camera but stay constraint at the vertical axis(so rotate only on the vertical axis), best example are the 2d trees which are always facing the camera except in top view.

right now I’ve got

    void Update()
    {
        transform.LookAt(Camera.main.transform);
    }

Thank’s for the help

Boobi

Here’s one simple way:

Vector3 target = Camera.main.transform;
target.y = transform.position.y;
transform.LookAt(target);

yep but Unity keeps saying me that we can transform a transform to a vector 3 oO

I’ve tried that already

Vector3 pos = Camera.main.transform.position;

I guess i need more coffee this morning…

cheers…