Understanding transform.LookAt()

Hi all! I was trying to make the face of my character to look at some target, I used lookat function but it was always rotating the head in some other direction and head was never facing the target, but when I tried this on cube the cube rotates exactly the way it should. Then I made the head child of an empty gameObject and pass the empty parent gameObject as head and everything worked fine. So my question is what was the problem before making this parent child realtionship? Thanks in advance.

So essentially the LookAt() function takes a transforms forward, and points it towards another transforms current World Position.

So if your transform you’re trying to rotate to lookat something has its front not on the forward Vector, it might give you a weird rotation similar to what you’re experiencing.

So the child parent setup you mentioned is likely the easiest way to solve your issue, now if you’re up for doing some Vector maths, you could correct your rotation issue.