10.02.2013, 22:38
if player camera is facing the same way as player ? how to get
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));
}
new
Float:camPos[3],
Float:camVector[3];
GetPlayerCameraPos(playerid, camPos[0], camPos[1], camPos[2]);
GetPlayerCameraFrontVector(playerid, camVector[0], camVector[1], camVector[2]);
DistanceCameraTargetToLocation(camPos[0], camPos[1], camPos[2], x, y, z, camVector[0], camVector[1], camVector[2]);