25.03.2019, 21:57
Help me please calculate the coordinates of the sight using camerapos + camerafrontvector to get the same data as in GetPlayerLastShotVectors (origin position)
new
Float:fPX, Float:fPY, Float:fPZ,
Float:fVX, Float:fVY, Float:fVZ,
Float:object_z,Float:zzz;
const
Float:disttt = 2.75;
GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
GetPlayerFacingAngle(playerid,zzz);
object_z = fPZ + floatmul(fVZ, disttt);
CreateObject(2707, fPX+disttt*-floatsin(zzz,degrees), fPY+disttt*floatcos(zzz,degrees), object_z+0.14, 0.0000000,0.0000000,0.0000000, 100); // my origin
CreateObject(2707, unoccupiedData[PR_origin][0],unoccupiedData[PR_origin][1],unoccupiedData[PR_origin][2], 0.0000000,0.0000000,0.0000000, 100); // origin
new
Float:fPX, Float:fPY, Float:fPZ,
Float:fVX, Float:fVY, Float:fVZ,
Float:object_x, Float:object_y, Float:object_z
Float:zzz;
const Float:fScale = 2.75; // 2.76;
GetPlayerCameraPos(playerid, fPX, fPY, fPZ);
GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ);
GetPlayerFacingAngle(playerid,zzz);
fVX += floatsin(-zzz+1.5, degrees);
fVY += floatcos(-zzz+1.5, degrees);
object_x = unoccupiedData[PR_origin][0] + (fVX * fScale);
object_y = unoccupiedData[PR_origin][1] + (fVY * fScale);
object_z = unoccupiedData[PR_origin][2] + (fVZ * fScale);
CreateObject(2707, object_x, object_y, object_z, 0.0000000,0.0000000,0.0000000, 100);
Try this.
Fire A weapon Get the origin / hitpoint of the shot Use https://sampwiki.blast.hk/wiki/VectorSize Subtract the result this from camera front vector GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ) That should give you a constant vector you can add to GetPlayerCameraFrontVector(playerid, fVX, fVY, fVZ); to figure out where the shot came from. Once you have your constant then test it you might have to compensate for facing angle? Not sure test it out. |