Spawn Object Behind Player
#1

I already have the command set up.

The problem is how do you spawn and object (Like an explosive barrel) behind a player no matter which direction they are facing?

Thanks in advance!
Reply
#2

you need to get the facing angle of the person. use the function 'GetXYInFrontOfPlayer'. It can be found on this forum
Reply
#3

Here are a few of them, I had in hand
pawn Код:
stock GetXYInFrontOfPlayer(playerid,&Float:x,&Float:y,Float:dis)
{
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    GetPlayerFacingAngle(playerid,pos[2]);
    GetXYInFrontOfPoint(pos[0],pos[1],x,y,pos[2],dis);
}

stock GetXYBehindPlayer(playerid,&Float:x,&Float:y,Float:dis)
{
    new Float:pos[3];
    GetPlayerPos(playerid,pos[0],pos[1],pos[2]);
    GetPlayerFacingAngle(playerid,pos[2]);
    GetXYBehindPoint(pos[0],pos[1],x,y,pos[2],dis);
}

stock GetXYInFrontOfPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:angle,Float:distance)
{
    x2 = x + (distance * floatsin(-angle,degrees));
    y2 = y + (distance * floatcos(-angle,degrees));
}

stock GetXYBehindPoint(Float:x,Float:y,&Float:x2,&Float:y2,Float:angle,Float:distance)
{
    x2 = x - (distance * floatsin(-angle,degrees));
    y2 = y - (distance * floatcos(-angle,degrees));
}
Reply


Forum Jump:


Users browsing this thread: