SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 13/01/2011, 08:09 PM   #1
MJ!
Huge Clucker
 
Join Date: Nov 2009
Posts: 213
Reputation: 0
Exclamation Help For Angle Between Two Points, for SetPlayerAttachedObject

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 Code:
Float:GetRotationBetweenPoints(Float:x1, Float:y1, Float:x2, Float:y2)
    return Float:(180-atan2(x1-x2,y1-y2));

pawn Code:
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 ...
MJ! is offline  
Old 13/01/2011, 08:54 PM   #2
Babul
High-roller
 
Babul's Avatar
 
Join Date: Sep 2009
Location: in a cement block
Posts: 1,781
Reputation: 251
Default Re: Help For Angle Between Two Points, for SetPlayerAttachedObject

http://forum.sa-mp.com/showthread.php?t=209102
__________________
FireWorks

new sscanf2 custom specifiers available for Download, read the Release Topic
Babul is offline  
Old 13/01/2011, 08:56 PM   #3
MJ!
Huge Clucker
 
Join Date: Nov 2009
Posts: 213
Reputation: 0
Default Re: Help For Angle Between Two Points, for SetPlayerAttachedObject

Errm, i know with SetObjectRot ... the problem it's with SetPlayerAttachedObject
MJ! is offline  
Old 13/01/2011, 09:27 PM   #4
Babul
High-roller
 
Babul's Avatar
 
Join Date: Sep 2009
Location: in a cement block
Posts: 1,781
Reputation: 251
Default Re: Help For Angle Between Two Points, for SetPlayerAttachedObject

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"
__________________
FireWorks

new sscanf2 custom specifiers available for Download, read the Release Topic
Babul is offline  
Old 14/01/2011, 11:50 AM   #5
MJ!
Huge Clucker
 
Join Date: Nov 2009
Posts: 213
Reputation: 0
Default Re: Help For Angle Between Two Points, for SetPlayerAttachedObject

Nop, that doesn't works ...

I tryed in two ways and it doesn't worked ...
pawn Code:
(-90-AngleBetweenPoints(tpos[x],tpos[y],ppos[x],ppos[y]))
pawn Code:
(-90-AngleBetweenPoints(ppos[x],ppos[y],tpos[x],tpos[y]))

Result:
MJ! is offline  
Old 14/01/2011, 01:12 PM   #6
Babul
High-roller
 
Babul's Avatar
 
Join Date: Sep 2009
Location: in a cement block
Posts: 1,781
Reputation: 251
Default Re: Help For Angle Between Two Points, for SetPlayerAttachedObject

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
__________________
FireWorks

new sscanf2 custom specifiers available for Download, read the Release Topic
Babul is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[HELP]SetPlayerAttachedObject <Weponz> Help Archive 1 07/01/2011 04:03 PM
0.3c SetPlayerAttachedObject !Pumpkin Help Archive 1 04/12/2010 09:58 PM
[HELP] SetPlayerAttachedObject Pooh7 Help Archive 1 03/12/2010 01:32 PM
[BUG] SetPlayerAttachedObject [NeS]Justin Help Archive 2 29/11/2010 07:48 PM
Adding Points, /points and Hitman into a Roleplay Script Despare Help Archive 2 27/12/2009 01:35 PM


All times are GMT. The time now is 07:58 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.