# How to set an object orientation using the Right and Up vectors

Hi,

I am trying to replicate the orientation of an object in Unity using its orientation description extracted from another tool. (see xml below)
The orientation is described by its position (origin) and its right (VX) and Up (VY) vectors.
(to start simple these are just rotating on one axis)
Could you help me figure out how I should use these data in Unity, and how to code it?

45 Degrees rotation

90 Degrees rotation

135 Degrees rotation

180 Degrees rotation

I used the following code for tests.
It seems to be working fine for every rotation, except for the 180 deg rotation that does seem to work, and set my object back to 0 deg.
I cannot figure out why!!!
Am I missing something obvious?

Is there another way, a proper way of coding this?

function Update () {
myInput = Input.inputString;

if(myInput == “a”){
transform.right = Vector3(1,0,0);
transform.up = Vector3(0,1,0);
}
if(myInput == “s”){
transform.right = Vector3(0.707,0.707,0);
transform.up = Vector3(-0.707,0.707,0);
}
if(myInput == “d”){
transform.right = Vector3(0,1,0);
transform.up = Vector3(-1,0,0);
}
if(myInput == “f”){
transform.right = Vector3(-0.707,0.707,0);
transform.up = Vector3(-0.707,-0.707,0);
}
if(myInput == “g”){
transform.right = Vector3(-1,0,0);
transform.up = Vector3(0,-1,0);
}
if(myInput == “h”){
transform.right = Vector3(-0.707,-0.707,0);
transform.up = Vector3(0.707,-0.707,0);
}
if(myInput == “j”){
transform.right = Vector3(0,-1,0);
transform.up = Vector3(1,0,0);
}
if(myInput)
print(myInput);
}

Thanks

Vanderic74

BTW, the key “g” is the part if the code that does not work.
Thanks
V.