[BUG]SetObjectRot Does Not Work On Attached Objects? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [BUG]SetObjectRot Does Not Work On Attached Objects? (
/showthread.php?tid=198672)
[BUG]SetObjectRot Does Not Work On Attached Objects? -
The_Gangstas - 12.12.2010
in a command.
pawn Код:
DestroyObject(GpsPickups[playerid]);
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
GpsPickups[playerid] = CreateObject(1318,x,y,z,0,0,0,40);
AttachObjectToVehicle(GpsPickups[playerid],GetPlayerVehicleID(playerid), 0, 5, 0, 0, 0, 0);
then in a update timer which works fine.
pawn Код:
SetObjectToFaceCords(GpsPickups[playerid], x1, y1, z2);
x1 and y1 are the 2d positions and z2 is the players Z
pawn Код:
stock SetObjectToFaceCords(objectid, Float:x1, Float:y1, Float:z1)
{
new Float:x2,Float:y2,Float:z2;
GetObjectPos(objectid, x2,y2,z2);
new Float:DX = floatabs(x2-x1);
new Float:DY = floatabs(y2-y1);
new Float:DZ = floatabs(z2-z1);
new Float:yaw = 0;
new Float:pitch = 0;
if(DY == 0 || DX == 0)
{
if(DY == 0 && DX > 0) {
yaw = 00;
pitch = 0; }
else if(DY == 0 && DX < 0) {
yaw = 180;
pitch = 180; }
else if(DY > 0 && DX == 0) {
yaw = 90;
pitch = 90; }
else if(DY < 0 && DX == 0) {
yaw = 270;
pitch = 270; }
else if(DY == 0 && DX == 0) {
yaw = 0;
pitch = 0; }
}
else
{
yaw = atan(DX/DY);
pitch = atan(floatsqroot(DX*DX + DZ*DZ) / DY);
if(x1 > x2 && y1 <= y2) {
yaw = yaw + 90;
pitch = pitch - 45; }
else if(x1 <= x2 && y1 < y2) {
yaw = 90 - yaw;
pitch = pitch - 45; }
else if(x1 < x2 && y1 >= y2) {
yaw = yaw - 90;
pitch = pitch - 45; }
else if(x1 >= x2 && y1 > y2) {
yaw = 270 - yaw;
pitch = pitch + 315; }
if(z1 < z2)
pitch = 360-pitch;
}
SetObjectRot(objectid, 0, 0, yaw);
SetObjectRot(objectid, 0, pitch, yaw+90);
}
Re: [BUG]SetObjectRot Does Not Work On Attached Objects? -
niCe - 12.12.2010
You set the rotation with the AttachObjectToVehicle (last 3 parameters).
Re: [BUG]SetObjectRot Does Not Work On Attached Objects? -
The_Moddler - 12.12.2010
I guess that you will have to use this:
Код:
Float:RotX The X rotation between the object and the vehicle.
Float:RotY The Y rotation between the object and the vehicle.
Float:RotZ The Z rotation between the object and the vehicle.
Код:
AttachObjectToVehicle(objectid, vehicleid, Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ, Float:fRotX, Float:fRotY, Float:RotZ);
niCe won
Re: [BUG]SetObjectRot Does Not Work On Attached Objects? -
The_Gangstas - 12.12.2010
if i use those. it doesnt point the object to the location..
could you help me make it point to the location? i tried everything..