Setting a players angle
#1

Is there a way to set a players angle towards an object?
Like whenever I call this function it'll set the players angle towards that object?
Reply
#2

i think all you could do is look at the object IG then /save angle then when player spawns setplayerfacingangle or spawninfo
Reply
#3

it is possible.

https://sampwiki.blast.hk/wiki/SetPlayerCameraLookAt
Reply
#4

ohhh i didnt actually knew that there was a function like that i never even tested it thx for telling that there is such functions
Reply
#5

I have this VERY OLD function from a VERY old script of mine, so it's probably not the best, but it works:

pawn Код:
stock SetObjectFacePlayer(Float:Px, Float:Py, Float:x, Float:y)
{
    new Float: 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);
    return floatround(Pa);
}
It'll return the z rotation for your object.

Px + Py = Player X/Y coords.
x + y = Object x/y coords.
Doesn't support Z height, but that's generally not needed.


EDIT: There's also this: http://forum.sa-mp.com/showthread.ph...3D#post1498305
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)