Help For Angle Between Two Points, for SetPlayerAttachedObject
#1

Hello guys. I have attached an object up to my head ( an arrow ), and i want, like the arrowhead to be directed toward a player. And i did like this:

pawn Код:
Float:GetRotationBetweenPoints(Float:x1, Float:y1, Float:x2, Float:y2)
    return Float:(180-atan2(x1-x2,y1-y2));
pawn Код:
public OnPlayerUpdate(playerid)
{
    new Float:x1,Float:x2,Float:y1,Float:y2,Float:z1,Float:z2;
    GetPlayerPos(playerid,x1,y1,z1);
    GetPlayerPos(Target[playerid],x2,y2,z2);
    new Float:arrowhead = GetRotationBetweenPoints(x1, y1, x2, y2);
    SetPlayerAttachedObject(playerid, 0, 1318, 1, 0.74976, 0.159999, 0.035997, arrowhead);
    return 1;
}
But the arrowhead, doesn't coordinate me correct. I think I must use my Angle, because the attached_object's rY & rZ is changing when i move ...
Reply
#2

https://sampforum.blast.hk/showthread.php?tid=209102
Reply
#3

Errm, i know with SetObjectRot ... the problem it's with SetPlayerAttachedObject
Reply
#4

i mean the rotation formula. is it working if the object is not attached? iam using another one, and thats doing well. i think that 180-atan2(x1-x2,y1-y2) is the wrong part. to get the attached objects rotation right, you only need to subtract the players rotation.
the formula in the other post is
Angle=-(90+(atan2(YA-YB,XA-XB)));
coz player/object rotations are left/right "handed"
Reply
#5

Nop, that doesn't works ...

I tryed in two ways and it doesn't worked ...
pawn Код:
(-90-AngleBetweenPoints(tpos[x],tpos[y],ppos[x],ppos[y]))
pawn Код:
(-90-AngleBetweenPoints(ppos[x],ppos[y],tpos[x],tpos[y]))
Result:
Reply
#6

hm. i see the arrow is sticky to the spine. its always pointing to "your back right". let the other guy move around you and look if the arrow is rotating smoothly, i mean if its 1 exact rotation if the guy is walking around you. if so, you only need to apply an offset to the rotation. like 120 degrees
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)