SetObjectFacingPlayer (seen it before, removed?)
#1

I've seen this one been used before, now it doesn't work.
Anyone know how I can get this function back?
If you have to code for it, please help me out
Reply
#2

Set the object to face the player or the player to face the object? It could be fairly simple to pretty complex. If it's just the Z angle of the object / player then it's pretty simple. You can get the 2D angle between them and just set it. If you were talking about an object / player that needs to point at another object / player in 3 dimensions, it's harder. I have a few functions lying around though...
Reply
#3

Awesome, I am looking to make an object face a player. (eg: Shark -> Player)
Could you please post the code for it? I don't know how to make it..

Thanks very much
Reply
#4

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);
}
This is a custom function I made for my own server, let me explain how to use it:

pawn Код:
CreateObject(model, x, y, z, rx, ry, SetObjectFacePlayer(objectx, objecty, playerx, playery)+offset_if_you_need_one);
Doesn't affect rx or ry though. I'd like to have that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)