- Home /
modify mesh local direction... (defining two directions at once)
I try to modify direction of the mesh through specifying direction in world space,Like this:
transform.forward = Vector3.right;
transform.right = Vector3.up;
but not work togehter,only the last statement is feasible.
how can I do that?
Answer by GameVortex · Dec 17, 2013 at 02:54 PM
Setting the direction using .right will sort of override the direction you set to .forward because it does not know explicitly what direction the other axis should be in when you set one direction.
To specify the entire direction you can use Quaternion.LookRotation which takes the forward axis and the up axis as parameters:
transform.rotation = Quaternion.LookRotation(Vector3.right, Vector3.forward);
Note that we have to use Vector3.forward as the second parameter instead of Vector3.up because we are setting the Up direction of the rotation and not the Right direction.
You are very welcome. Remember to mark the question as answered. =)
Your answer
![](https://koobas.hobune.stream/wayback/20220613124340im_/https://answers.unity.com/themes/thub/images/avi.jpg)