- Home /
Locking x- axis
Currently I'm using the below code to look at an object, it rotates a capsule towards it: transform.LookAt(Forward1);
I only want it to rotate around its local x axis and to disable the others. I've tried
transform.LookAt(Vector3(Forward1.position.x, transform.position.y, transform.position.z));
But it rotates "90" before the application starts ending up not pointing at the main object at all.
How might I do this?
Thanks in advance!
Answer by Mike 3 · Aug 03, 2010 at 11:13 AM
I think this should do it:
transform.LookAt(Vector3(0, Forward1.y, Forward1.z));
Whichever axis you want to look around, set to 0, that's about it
O$$anonymous$$G! I've been trying to figure this out for like 1 hour now. Thank you so much! :)
What if I want to look at an angle? say angle = 45.0f.
transform.LookAt(Vector3(rojectile.angle,0,0), Vector3.right);
P.S. : I did not want to start another question I have something very relevant here.
Thank you very much.
Your answer
Follow this Question
Related Questions
Lock rotation axis? 4 Answers
LookAt() and RotateAround() 1 Answer
hoe to rotate a AI as a animation 1 Answer
Rotate to a certain position 2 Answers
LookAt once 0 Answers