Determine the point you're looking at
#1

Hello everybody,
I want to create something like a rocket which shoots in the direction I look and explodes as soon as it colides.
The movement and explosion is no problem (Thus MoveObject returns the time the movement takes), but I have problems in determining the coordinates of the point I'm looking at.

The only way I could think of is with MapAndreas which I'm using already, but I have still can't figure out how to calculate the proper position.

I hope you understand my problem and are able to help me.

Regards
Padarom
Reply
#2

not sure:
pawn Код:
stock IsPlayerLookingAtPoint(playerid,Float:X,Float:Y,Float:Z,Float:Distance,RadiosToPoint)
{
    new Float:CX,Float:CY,Float:CZ,Float:FX,Float:FY,Float:FZ;
    new Float:PX,Float:PY,Float:PZ,Float:D;
    if(IsPlayerInRangeOfPoint(playerid,Distance,X ,Y ,Z))
    {
        GetPlayerCameraPos(playerid,CX,CY,CZ);
        GetPlayerCameraFrontVector(playerid, FX, FY, FZ);
        PX = FX*D+CX;
        PY = FY*D+CY;
        PZ = FZ*D+CZ;
        D = floatsqroot(((PX - X) * (PX - X)) + ((PY - Y) * (PY - Y)) + ((PZ - Z) * (PZ - Z)));
        if(D < RadiosToPoint)
        {
            return 1;
        }
    }
    return 0;
}
and then use at the command:
pawn Код:
new Float:x,Float:y,Float:z;
if(IsPlayerLookingAtPoint(Float:x,Float:y,Float:z,etc);
MoveObject(model,Float:x,Float:y,Float:Z);
not sure if it will work
it's just a sort out of how you would implement it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)