transform.rotation.z coming in wrong

Hi, I’m trying to rotate an object placed between two other objects to line up between them.

angle = Vector3.Angle( target.transform.position, trigger.transform.position);        		
transform.rotation.z = angle * Mathf.Deg2Rad;

But as you can see in the pic the object is not lining up properly. (the green line is a Debug.DrawLine between the two points)

alt text

I’m not sure what I’m doing wrong here, does anyone have any ideas?

Never, ever change .rotation for any reason. It explains this over and over in the docs.

The value you are setting has utterly no connection to what you think it does.

(OK, if you have a degree in mathematics, you can investigate .rotation !!)

Simply set the “Euler angles” as you wish:

Even better, just “rotate” the object as you wish: