04.10.2010, 19:35
Thanks samgreen, I do need some assistance with it.
I'm trying to check if the player is looking at some point, and do something if he does.
This is the code:
I never worked with cameras before (Except doing the class screen).
The problem in this code is: wherever I look, it does something, doesn't matter where am I looking at, though it supposed to do something when I'm looking at the exact point.
I'm trying to check if the player is looking at some point, and do something if he does.
This is the code:
pawn Код:
stock IsPlayerLookingAtFire(playerid, fireid)
{
new
Float:cX, Float:cY, Float:cZ,
Float:cPosX, Float:cPosY, Float:cPosZ,
Float:x1, Float:y1, Float:z1,
Float:x2, Float:y2, Float:z2,
Float:dX, Float:dY, Float:dZ;
GetVehiclePos(GetPlayerVehicleID(playerid), x1, y1, z1);
GetPlayerCameraPos(playerid, cPosX, cPosY, cPosZ);
GetPlayerCameraFrontVector(playerid, cX, cY, cZ);
x2 = FireInfo[fireid][firePosX];
y2 = FireInfo[fireid][firePosY];
z2 = FireInfo[fireid][firePosZ];
new Float:Dist = GetDistanceBetweenPoints(x1, y1, z1, x2, y2, z2);
dX = cPosX + floatmul(cX, Dist);
dY = cPosY + floatmul(cY, Dist);
dZ = cPosZ + floatmul(cZ, Dist);
if(GetDistanceBetweenPoints(x1, y1, z1, dX, dY, dZ) <= 50.0)
{
return true;
}
return false;
}
The problem in this code is: wherever I look, it does something, doesn't matter where am I looking at, though it supposed to do something when I'm looking at the exact point.