- Home /
LookAt Limit Up and Down rotation only
i have 2 cubes in my one is static that looks at the other object so when i move the other object the first cube should rotate it self to the other one but the problem is i want it to do this only in the Z axis or up and down only = 1 axis , but when ever it start looking the x,y,z all change while i want them all to remain 0 except the one that looks up and down at the other cube i tried something to limit the Y and it worked but it doesnt work with Z , any help ?
Please at least try to use complete sentences with proper grammar and punctuation. It is really hard to figure out what your talking about.
Also it would help if you provided some information, most notably the script you use for rotating the cube.
Answer by midomido · Jul 27, 2012 at 11:17 PM
never mind , my problem was that when my 1st cube starts to LookAt(Cube2) all the axis start to change (X,Y,Z) all i wanted is the Z axis only , i fixed this using
var relativePos = Vector3 Cube2.position - Cube1.position; var rotation = Quaternion.LookRotation(relativePos); Cube1.rotation = rotation;
thanks for your help though
Answer by IndieScapeGames · Jul 26, 2012 at 07:24 PM
Please post some code and we'll be able to help better. We don't even know what language you are using.
I would say that use the same logic as what is working for the Y axis, but in the parameters 0 out the Y information, and put the information in the Z's place.
Your answer
Follow this Question
Related Questions
Making a specific axis look at an object 2 Answers
LookAt on one axis 2 Answers
rotate gameobject 1 Answer
LookAt something while rotating on z? 1 Answer
How can I rotate towards/look at a specific axis of a collided object? 2 Answers