Vector3.left Not Working
I've attached a cylinder to a controller and simply want it to look at the other controller. Simple, right?
public Transform target;
void Update () {
transform.LookAt(target, Vector3.[up, down, left, right, forward, or back]);
}
But, for the life of me, I can't point the correct vertice towards the other controller!!
Vector3.up and Vector3.down work as expected.
So does Vector3.forward and Vector3.back
But when I try Vector3.left or Vector3.right, it snaps into the same position as Vector3.forward. It refuses to point the at the other controller. The weird thing is that I can see it pointing at the other controller on the first frame but then snaps into the Vector3.forward position.
Can anyone help? Thanks.
Please, read carefully the documentation
The vector you specify as second argument as nothing to do with the direction your object must face. It's simply the reference vector to use so that your transform's up vector is correctly oriented. Usually, you have to specify Vector3.up
.
You surely have a problem with the target.
Agreed. That second param can be a bit tricky: imagine your transform as a camera. Even when you point it at an object, you can still rotate it around: and take a picture sideways, or even upside down. That rotation is exactly what the second param specifies: In what world direction, is the top of your camera frame?
Your answer
Follow this Question
Related Questions
HTC viveコントローラの取得値の移動平均(フィルタ)について 0 Answers
how can I "play" the whole MoveTowards sequence after one click? 1 Answer
How to compare limits for creating new objects in world space? 0 Answers
Helicopter Move Local Position,Local Position 1 Answer
Unity2d worldspace / local space vector 3 help needed 0 Answers