- Home /
vector3.up and vector3.down?
i know vector3.up means 0,1,0 and vector3.down means 0,-1,0 but when i use them i don't get expected results. i want to change a GameObject's rotation's axis so i can get what I want.
please check this video https://imgur.com/LbW9Po1 and help me with this. thank you!
void R_()
{
if (initializeMove==false)
{
Obj = GameObject.Find("RObject");
foreach (GameObject ObjectFound in GameObject.FindGameObjectsWithTag("R"))
{
ObjectFound.transform.parent.parent = Obj.transform;
}
eul = Obj.transform.eulerAngles;
initializeMove=true;
}
else
{
/*problem*/Quaternion deltaRotation = Quaternion.AngleAxis(20f*Time.deltaTime, Vector3.down);
//whenever i change `down` to `up`, i don't get the opposite results.
Obj.transform.rotation *= deltaRotation;
if (Obj.transform.rotation[0] >= 0)
{
eul = eul + new Vector3(-90, 0, 0);
Obj.transform.eulerAngles = eul;
whichMove="";
initializeMove=false;
//ReassignTags("R_");/////////////////////////////////////////////////
}
}
}
void Update()
{
R_();
}
also, why should i use up
and down
if i want to change the X rotation axis?
Quaternion multiplication is not commutative. So if you have two quaternions q1 and q2 doing q1*q2
is not the same as q2*q1
. You may want to have a look at this Numberphile video on quaternions.
Generally quaternions should be thought of as functions. So the quaternion on the left is acting like a transformation on the argument on the right.
To actually rotate a vector by a quaternion you have to do q v (q^-1) where "q^-1" is the complex conjugate of q. $$anonymous$$athematically to apply the transformation of q1 first, followed by the transformation of q2 you have to do q2*q1 * v * (q1^-1)*(q2^-1)
. If you combine q2 and q1 into one quaternion q like this q= q2 * q1
you can just do q*v*(q^-1)
. In Unity when you do q * v
it actually does q * v * (q^-1)
Your answer
Follow this Question
Related Questions
Calculating a Respawn Position at Runtime 3 Answers
Mouse-following script freezes Unity. 1 Answer
Can someone help me to understand what vector3.lerp does and can be used for 2 Answers
problem Changing Scales in Script -C# 4 Answers
Cannot modify a value type return value of `UnityEngine.Transform.position'. Can anyone help ? 1 Answer