GetVehicleRotationQuat always returning {0.5, 0.5, 0.5, 0.5} after spawning
#1

Hi,,

I have this code:
Код:
CreateVehicle(vehicletype, 0, 0, 5, any_rotation, -1, -1, -1);
new Float:q[4];
GetVehicleRotationQuat(vehicleid, q[0], q[1], q[2], q[3]);
printf("QUAT: %f %f %f %f", q[0], q[1], q[2], q[3]);
This always prints "QUAT: 0.5 0.5 0.5 0.5" when spawning a vehicle with any rotation. I've read somewhere this is a known bug. After a player enters the vehicle it works as it should...

Is there a way to work around this issue?
Reply
#2

Bump
(I know it hasn't been exactly 24hrs, but it was very much snowed under and i don't expect an answer on page 4)
Reply
#3

Bump
Reply
#4

I don't think bumping will result in real answers, except "stop bumping" etc... Since nobody seems to have an answer.

It's a SAMP problem, since the vehicle wasn't updated yet (or st. like this).

Try if GetVehicleZAngle returns a correct value after spawning. If not, I guess your question is answered.

There is actually no real fix, but since YOU spawn the vehicle, you have the rotation already right?
Reply
#5

yup, and i am storing it, but i need to know a way/moment when to re-apply the rotation to fix the problem; I want a player to interact with with the vehicle (standing behind it; i'm using the mathplugin which uses GetVehicleRotationQuat to determine the rotation) while no-one has entered the vehicle yet.
Reply
#6

I ended up not using the math plugin due to this issue. the rotationquat doesn't seem to update while no player is inside the vehicle.

Here is my resulting method if anyone cares:
Код:
stock IsPlayerAtVehicleTrunk(playerid, vehicleid)
{
	new Float:sizex, Float:sizey, Float:unused, Float:bumperz, 
	Float:posx, Float:posy, Float:posz, Float:posa;

	//Get all required data
	GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, sizex, sizey, unused);
	GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_REAR_BUMPER_Z, unused, unused, bumperz);
 	GetVehiclePos(vehicleid, posx, posy, posz); 
 	GetVehicleZAngle(vehicleid, posa);

 	//A check to determine if the player is actually near the vehicle. 
 	//If the player is not near the vehicle we can stop this script from doing more 'complex' calculations.
	if(!IsPlayerInRangeOfPoint(playerid, sizey, posx, posy, posz))
		return 0;

	//Calculate trunk position
	posx += (sizey / 2) * floatsin(-posa + 180, degrees);
	posy += (sizey / 2) * floatcos(-posa + 180, degrees);
	posz += bumperz;

	return IsPlayerInRangeOfPoint(playerid, sizex / 2, posx, posy, posz);
}
Reply
#7

That's the more easy way, yeah.

Is it a Math Plugin issue or does your code work even with just spawned vehicles?
Reply
#8

It's an issue with SA-MP; you can't rely on GetVehicleRotationQuat when the vehicle isn't ocupied. Since the math plugin uses GetVehicleRotationQuat, it may return faulty information. GetVehicleZAngle, however, returns the right information even when the vehicle isn't ocupied. But you can't calculate the exact trunk location due to not taking the x and y rotations in consideration in the calculation.
Reply
#9

in ur code u didnt define vehicleid
maybe this the problem? look for silly mistakes too

if ur taking the quat right after creating veh /spawning it might not work try making timer?

experiment with it, but i see you might have solved it different way now
Reply
#10

It never works when there is not player in the vehicle, i thoroughly tested it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)