GetAimingPos
#5

Quote:

Float: DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ, Float:ObjX, Float:ObjY, Float:ObjZ, Float:FrX, Float:FrY, Float:FrZ) {

new Float:TGTDistance;

// get distance from camera to target
TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));

new Float:tmpX, Float:tmpY, Float:tmpZ;

tmpX = FrX * TGTDistance + CamX;
tmpY = FrY * TGTDistance + CamY;
tmpZ = FrZ * TGTDistance + CamZ;

return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}

stock IsPlayerAimingAt(playerid, Float: x, Float:y, Float:z, Float:radius)
{
new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float :fz;
GetPlayerCameraPos(playerid, cx, cy, cz);
GetPlayerCameraFrontVector(playerid, fx, fy, fz);
return (radius >= DistanceCameraTargetToLocation(cx, cy, cz, x, y, z, fx, fy, fz));
}

This is what i now got:
Quote:

new Float:gtpos[50];
GetPlayerCameraPos(playerid,gtpos[0],gtpos[1],gtpos[2]);
GetPlayerCameraFrontVector(playerid,gtpos[3],gtpos[4],gtpos[5]);

for(new checkdist=0;checkdist<=50;checkdist+=5)
{
gtpos[6] = gtpos[0] + floatmul(gtpos[3], float(checkdist));
gtpos[7] = gtpos[1] + floatmul(gtpos[4], float(checkdist));
gtpos[8] = gtpos[2] + floatmul(gtpos[5], float(checkdist));
marker[playerid][checkdist] = CreatePickup(1239,23,gtpos[6],gtpos[7],gtpos[8]);
}

The problem is, that it work fine, if im not aiming somewhere...
If i use a weapon to aime somewhere, its getting wrong...
Reply


Messages In This Thread
GetAimingPos - by Trooper[Y] - 12.08.2010, 18:53
Re: GetAimingPos - by Trooper[Y] - 12.08.2010, 19:17
Re: GetAimingPos - by Trooper[Y] - 13.08.2010, 10:21
Re: GetAimingPos - by Hiddos - 13.08.2010, 10:29
Re: GetAimingPos - by Trooper[Y] - 13.08.2010, 10:33
Re: GetAimingPos - by iggy1 - 13.08.2010, 11:02
Re: GetAimingPos - by Trooper[Y] - 22.08.2010, 21:11
Re: GetAimingPos - by Trooper[Y] - 29.08.2010, 20:48
AW: GetAimingPos - by Trooper[Y] - 29.09.2010, 20:06
Re: GetAimingPos - by Mauzen - 29.09.2010, 21:20

Forum Jump:


Users browsing this thread: 1 Guest(s)