- Home /
Question by
dot · Nov 09, 2010 at 11:15 PM ·
transformtransformdirection
what's the difference between TransformDirection(Vector3.right) and transform.right?
if I have the code from documentation
// Calculate the x-axis relative to the camera
var cam : Transform = Camera.main.transform;
var cameraRelativeRight : Vector3 = cam.TransformDirection (Vector3.right);
// Apply a force relative to the camera's x-axis
rigidbody.AddForce (cameraRelativeRight * 10);
wouldn't
rigidbody.AddForce(cam.right * 10);
do exactly the same?
Comment
Best Answer
Answer by Jesse Anders · Nov 09, 2010 at 11:28 PM
transform.right and transform.TransformDirection(Vector3.right) should have the same value (within numerical limits, at least). You see 'TransformDirection(Vector3.*) all the time in tutorials and code posted to the forums, which I suppose is because at some point someone wrote that in the documentation or some other reference, and now everyone thinks that's the way to do it. But you are correct that it should not be necessary to use TransformDirection() in this case.
Your answer
