How to get a line parallel to a plane?

I’m trying to get an object rotate on its Z axis so that its transform.up is parallel to another objects Y axis plane.

I don’t want it to rotate on any other axis than on Z.

if your position y is up and down, the rotation y axis wont point you up. think of y axis as spinning around on an up and down pole. z position is front and back, rotating z makes your character tilt left and right. i think of axis like a pole stuck through the gameobject…spin the pole for rotation. slide em back and forth for position.

i think x is what you want. its the side to side pole. you need to spin to look upwards.

you can get an object to face another object with only the x axis with:

	var target : GameObject;
	function Update () {
		var relativePos = target.transform.position - transform.position;
		var rotation = Quaternion.LookRotation(relativePos);
		transform.rotation.x = rotation.x;