Blockland Forums > Modification Help
Finding a Player's Roll Degree
Deathwishez:
I don't know how to find the roll. I've gotten pitch and yaw, but not roll.
Any help?
Night Fox:
You mean when they are in a vehicle?
Because, your head can't face anywhere other than up, without skis/a vehicle.
Deathwishez:
I don't want the roll value to rely on the vehicle.
So, the player in general. Inside, or outside, a vehicle.
Kalphiter:
--- Code: ---function axisToEuler(%axis)
{
%angleOver2 = getWord(%axis,3) * 0.5;
%angleOver2 = -%angleOver2;
%sinThetaOver2 = mSin(%angleOver2);
%cosThetaOver2 = mCos(%angleOver2);
%q0 = %cosThetaOver2;
%q1 = getWord(%axis,0) * %sinThetaOver2;
%q2 = getWord(%axis,1) * %sinThetaOver2;
%q3 = getWord(%axis,2) * %sinThetaOver2;
%q0q0 = %q0 * %q0;
%q1q2 = %q1 * %q2;
%q0q3 = %q0 * %q3;
%q1q3 = %q1 * %q3;
%q0q2 = %q0 * %q2;
%q2q2 = %q2 * %q2;
%q2q3 = %q2 * %q3;
%q0q1 = %q0 * %q1;
%q3q3 = %q3 * %q3;
%m13 = 2.0 * (%q1q3 - %q0q2);
%m21 = 2.0 * (%q1q2 - %q0q3);
%m22 = 2.0 * %q0q0 - 1.0 + 2.0 * %q2q2;
%m23 = 2.0 * (%q2q3 + %q0q1);
%m33 = 2.0 * %q0q0 - 1.0 + 2.0 * %q3q3;
return mRadToDeg(mAsin(%m23)) SPC mRadToDeg(mAtan(-%m13, %m33)) SPC mRadToDeg(mAtan(-%m21, %m22));
}
--- End code ---
Assuming %t will be their transform:
--- Code: ---%rot = axisToEuler(getWords(%t, 3, 9));
--- End code ---
And %rot will be something like this:
180.482 24.142 4.2039
Yaw Roll Pitch
Deathwishez:
You mean to tell me that this is my full equation?
--- Code: ---mRadToDeg(mATan(-(2.0 * (((getWord(%axis,0) * mSin(-(getWord(%axis,3) * 0.5))) * (getWord(%axis,2) * mSin(-(getWord(%axis,3) * 0.5)))) - (mCos(-(getWord(%axis,3) * 0.5)) * (getWord(%axis,1) * mSin(-(getWord(%axis,3) * 0.5)))))), (2.0 * (mCos(-(getWord(%axis,3) * 0.5)) * mCos(-(getWord(%axis,3) * 0.5))) - 1.0 + 2.0 * ((getWord(%axis,2) * mSin(-(getWord(%axis,3) * 0.5))) * (getWord(%axis,2) * mSin(-(getWord(%axis,3) * 0.5)))))))
--- End code ---
I got Pitch with one command, and Yaw with two.