Object offset position.
#1

I don't know how to explain what I want exactly, but to help explain here are two pages similar to what I want: 1, 2. Ok, so for example take this arrow:

What I want to know is if any player is in front of (in this case the arrow's tip) the object no matter the object's rotation. So, even if the arrow is rotated at 30.0, 50.0, 75.0 I want the arrow's tip. In this page programie wants the visible area of the traffic camera, that's almost exactly what I want but the reply there is not what I want. Picture a cone (or even just a line) coming off of the tip of the arrow, I want to know if a point is in this cone.


EDIT: I was thinking of using something like these,
pawn Код:
GetAttachedObjectPos(objectid, Float:offset_x, Float:offset_y, Float:offset_z, &Float:x, &Float:y, &Float:z)
{
    new Float:object_px,
        Float:object_py,
        Float:object_pz,
        Float:object_rx,
        Float:object_ry,
        Float:object_rz;
    GetObjectPos(objectid, object_px, object_py, object_pz);
    GetObjectRot(objectid, object_rx, object_ry, object_rz);
    new Float:cos_x = floatcos(object_rx, degrees),
        Float:cos_y = floatcos(object_ry, degrees),
        Float:cos_z = floatcos(object_rz, degrees),
        Float:sin_x = floatsin(object_rx, degrees),
        Float:sin_y = floatsin(object_ry, degrees),
        Float:sin_z = floatsin(object_rz, degrees);
    x = object_px + offset_x * cos_y * cos_z - offset_x * sin_x * sin_y * sin_z - offset_y * cos_x * sin_z + offset_z * sin_y * cos_z + offset_z * sin_x * cos_y * sin_z;
    y = object_py + offset_x * cos_y * sin_z + offset_x * sin_x * sin_y * cos_z + offset_y * cos_x * cos_z + offset_z * sin_y * sin_z - offset_z * sin_x * cos_y * cos_z;
    z = object_pz - offset_x * cos_x * sin_y + offset_y * sin_x + offset_z * cos_x * cos_y;
}

bool:IsPlayerBetweenPoints(playerid, Float:P_1[3], Float:P_2[3], Float:Dist)
{
    new Float:iDis = floatsqroot(floatpower(P_1[0]-P_2[0], 2)+floatpower(P_1[1]-P_2[1], 2)+floatpower(P_1[2]-P_2[2], 2));
    new Float:P_P[3]; GetPlayerPos(playerid, P_P[0], P_P[1], P_P[2]);
    new Float:pDis =
        floatsqroot(floatpower(P_1[0]-P_P[0], 2)+floatpower(P_1[1]-P_P[1], 2)+floatpower(P_1[2]-P_P[2], 2))+
        floatsqroot(floatpower(P_P[0]-P_2[0], 2)+floatpower(P_P[1]-P_2[1], 2)+floatpower(P_P[2]-P_2[2], 2));
//  new Float:pDis_1 = floatsqroot(floatpower(P_1[0]-P_P[0], 2)+floatpower(P_1[1]-P_P[1], 2)+floatpower(P_1[2]-P_P[2], 2)),
//      Float:pDis_2 = floatsqroot(floatpower(P_P[0]-P_2[0], 2)+floatpower(P_P[1]-P_2[1], 2)+floatpower(P_P[2]-P_2[2], 2));

    return (pDis<(iDis+Dist));
}
or like this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)