GetVehicleRotationQuat, What is what? -
milanosie - 12.08.2012
Quick question, never used GetVehicleRotationQuat before so want to be sure.
pawn Code:
GetVehicleRotationQuat(vehicleid, &Float:w, &Float:x, &Float:y, &Float:z)
What is the Float:w value in here?
Re: GetVehicleRotationQuat, What is what? -
Vince - 12.08.2012
Not sure. You need to convert it to Euler angles if you want to get yaw, pitch, roll.
Re: GetVehicleRotationQuat, What is what? -
milanosie - 12.08.2012
Quote:
Originally Posted by Vince
Not sure. You need to convert it to Euler angles if you want to get yaw, pitch, roll.
|
And what would I do to do that? Not really familiar with it,
Re: GetVehicleRotationQuat, What is what? -
Babul - 12.08.2012
iam using it to check if a vehicles "horizon" got flipped:
pawn Code:
forward OnPlayerKeyStateChange(playerid, newkeys, oldkeys); public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
if ((newkeys & KEY_CROUCH) && !(oldkeys & KEY_CROUCH))
{
if(IsPlayerInAnyVehicle(playerid))
{
new VehID,Float:VehPosX,Float:VehPosY,Float:VehPosZ,Float:VehSpdX,Float:VehSpdY,Float:VehSpdZ,Float:VehAngle,Float:VehSpeed,Float:Q[4];
//new Float:heading,Float:attitide,Float:bank;
VehID=GetPlayerVehicleID(playerid);
GetVehiclePos(VehID,VehPosX,VehPosY,VehPosZ);
GetVehicleZAngle(VehID,VehAngle);
GetVehicleVelocity(VehID,VehSpdX,VehSpdY,VehSpdZ);
VehSpeed=floatsqroot(VehSpdX*VehSpdX+VehSpdY*VehSpdY+VehSpdZ*VehSpdZ);
GetVehicleRotationQuat(VehID,Q[0],Q[1],Q[2],Q[3]);
new Float:sqw=Q[0]*Q[0];
new Float:sqx=Q[1]*Q[1];
new Float:sqy=Q[2]*Q[2];
new Float:sqz=Q[3]*Q[3];
new Float:bank=atan2(2*(Q[2]*Q[3]+Q[1]*Q[0]),-sqx-sqy+sqz+sqw);
if(floatabs(bank)>160 && VehSpeed<0.01)
{
SetVehiclePos(VehID,VehPosX,VehPosY,VehPosZ);
SetVehicleZAngle(VehID,VehAngle);
GameTextForPlayer(playerid,"~w~vehicle ~g~fl~h~ip~h~pe~h~d",2000,4);
}
return 1;
}
}
return 1;
}
it wont flip/stop you flying in a dodo while being flipped, due to the speed check - its' precision: one-hundert-percent. (iam not using 180 degrees but 160, in case my car stops on a hill, where it slips off anyways when moving too fast, thats why 160°. the speed check is not sensible enougn, multiply it by 10 for "less strict" behavior: speed-slipping slower than walking is ok?)
Re: GetVehicleRotationQuat, What is what? -
milanosie - 12.08.2012
I am trying to check if a vehicle is driving on a hill, would this work while using this?
Re: GetVehicleRotationQuat, What is what? -
Babul - 12.08.2012
yep. bank will be an angle of 0.0 when youre on flat ground, and when driving up a wall it will return 90.0, regardless if your car is tilted on its x/y axis, so you can detect if youre driving on a hanging curve (45 degrees) aswell. surprise yourself with a GameText showing the bank value in OnPlayerUpdate. enjoy!