GetVehicleRotationQuat, What is what?
#4

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?)
Reply


Messages In This Thread
GetVehicleRotationQuat, What is what? - by milanosie - 12.08.2012, 13:59
Re: GetVehicleRotationQuat, What is what? - by Vince - 12.08.2012, 14:10
Re: GetVehicleRotationQuat, What is what? - by milanosie - 12.08.2012, 14:29
Re: GetVehicleRotationQuat, What is what? - by Babul - 12.08.2012, 15:21
Re: GetVehicleRotationQuat, What is what? - by milanosie - 12.08.2012, 17:03
Re: GetVehicleRotationQuat, What is what? - by Babul - 12.08.2012, 17:39

Forum Jump:


Users browsing this thread: 1 Guest(s)