Detecting ground collision:
#1

The subject is quite explanatory itself. I'd like to know how I could detect a collision with the ground. Disregard any poor code optimization or errors, it's still a work in progress.

pawn Код:
new obj;

new Float:fXpos,
    Float:fYpos,
    Float:fZpos;

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    fX = fXpos;
    fY = fYpos;
    fZ = fZpos;

    obj = CreateDynamicObject(3786, fX, fY, fZ + 50.0, 0.0, 0.0, 0.0, 100);
    SendClientMessage(playerid, -1, "Information: You have called air support. The bomb will be dropped at:");

    new str[129];
    format(str, sizeof(str), "X: %f\nY: %f\n Z: %f", fXpos, fYpos, fZpos);
    SendClientMessage(playerid, -1, str);

    SetTimerEx("OBJ_CRASH", 4000, true, "i", playerid);
    return 1;
}

public OBJ_CRASH(playerid);
public OBJ_CRASH(playerid)
{
    SetObjectPos(obj, fXpos, fYpos, fZpos - 5.0);
    return 1;
}
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=120013
https://sampforum.blast.hk/showthread.php?tid=275492
https://sampforum.blast.hk/showthread.php?tid=273263

Choose one and use it to get Z.
I prefer the include (I really don't know why though) so:
pawn Код:
GetPointZPos(fX, fY, fZpos);
Then use fZpos instead of fZ.

Note: Your creating a dynamic object so you should use SetDynamicObjectPos
Note2: Use MoveDynamicObject instead as it would look more real (Just giving an idea)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)