Set Player Face Point?
#1

I don't know how the fuck to do this.

I need a function that will set a player's facing angle to look at an X/Y position coords.

This isn't working:

pawn Код:
//Credits to Zeex
stock SetPlayerLookAt(playerid, Float:X, Float:Y)
{
    new
    Float:pX,
    Float:pY,
    Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
    return SetPlayerFacingAngle(playerid, -acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
}
Reply
#2

PHP код:
SetPlayerFacingAngle 
should always be learn from usage General .. look how it's done

PHP код:
SetPlayerFacingAngle(playeridFloat:ang
i cant see that at your line

PHP код:
SetPlayerFacingAngle(playerid, -acos((pX) / floatsqroot((pX)*(pX) + (pY)*(pY))) - 90.0); 
check that line again . if that didnt help you that means you dident explain what you want exactly
Reply
#3

Quote:
Originally Posted by MCZOFT
Посмотреть сообщение
PHP код:
SetPlayerFacingAngle 
should always be learn from usage General .. look how it's done

PHP код:
SetPlayerFacingAngle(playeridFloat:ang
i cant see that at your line

PHP код:
SetPlayerFacingAngle(playerid, -acos((pX) / floatsqroot((pX)*(pX) + (pY)*(pY))) - 90.0); 
check that line again . if that didnt help you that means you dident explain what you want exactly
I know what SetPlayerFacingAngle is.

For instance, I have 24 unique spawn points that all face the same spot (an x/y coordinate). Instead of finding EVERY SINGLE facing angle, I have a loop to set the facing angle to face a coordinate, the center of a circle.

The stock above is not setting the facing angle accordingly, though.
Reply
#4

pawn Код:
stock SetPlayerLookAt(playerid, Float:X, Float:Y)
{
    new Float:Px, Float:Py, Float: Pa;
    GetPlayerPos(playerid, Px, Py, Pa);
    Pa = floatabs(atan((Y-Py)/(X-Px)));
    if (X <= Px && Y >= Py) Pa = floatsub(180, Pa);
    else if (X < Px && Y < Py) Pa = floatadd(Pa, 180);
    else if (X >= Px && Y <= Py) Pa = floatsub(360.0, Pa);
    Pa = floatsub(Pa, 90.0);
    if (Pa >= 360.0) Pa = floatsub(Pa, 360.0);
    SetPlayerFacingAngle(playerid, Pa);
}
Simple math.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)