LookAt not working correctly

Hello,

I have a trouble using LookAt method. I have a moving tank object, which should rotate its barrel toward static object while it’s moving.

Barrel should be rotated like this:

2870520--210329--Zajeta slika.JPG

In script, I use a method called LookAt:

But the barrel gets rotated in a wrong way:

2870520--210331--wrong.JPG

any ideas ?

Regards, L

Pay close attention to your tank barrels coordinates, in Unity the Y axis is up and Z is forward so Lookat will rotate a transform to point at a position along the Transforms Z axis.