- Home /
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.
Answer by toddisarockstar · Feb 08, 2015 at 01:45 AM
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;
}
For clarity I like to think of an aeroplane when working with rotations.
X = $$anonymous$$ch Y = Yaw Z = Roll
no, i think understand rotations. I really do need object 1's transform.up (y_pos+) to be parallel to object 2's y plane (as in the entire horizontal plain of that object. look at an objects y axis in rotation mode, and fill in the circle and beyond to get the plane that i need.) and I need the object 1's rotation to be in the z axis (as in when you move your head side to side, like tilting your head.)