SA-MP Forums Archive
How to get coordinates in center of an object? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: How to get coordinates in center of an object? (/showthread.php?tid=523129)



How to get coordinates in center of an object? - Hantex. - 30.06.2014

Hi guys, How can i to get coordinates in center of an object? (The object is 3004 [pool cue])


Re: How to get coordinates in center of an object? - Jefff - 30.06.2014

GetObjectPos ?


Re: How to get coordinates in center of an object? - Virtual1ty - 30.06.2014

Unfortunately running GetObjectPos on that specific object ID will return it's cue tip position, instead of the "center" position, so you will have to get the center pos by trial and error, AFAIK that cue stick is about a meter and a half long, so just add ±1,543 divided by 2* to either end of the stick to get position (relatively) in the middle of the pool cue.

* Got that number by measuring, it's not that "precise".

Edit: Use what Mauzen said, works precisely! You have to use trig to get the offsets right, though.


Re: How to get coordinates in center of an object? - Mauzen - 30.06.2014

You could take a look at this: https://sampforum.blast.hk/showthread.php?tid=407909
It should give you the correct center offset, you just need to consider rotation.


Re : How to get coordinates in center of an object? - Clad - 30.06.2014

Use this.


Re: How to get coordinates in center of an object? - Hantex. - 01.07.2014

Quote:
Originally Posted by Mauzen
Посмотреть сообщение
You could take a look at this: https://sampforum.blast.hk/showthread.php?tid=407909
It should give you the correct center offset, you just need to consider rotation.
Thanks, but now when i attach the object with another object (using the AttachObjectToObject) and i try to get the coordinates, the coordinates are all at 0.0.. how can I get the coordinates of an object attached?


Re: How to get coordinates in center of an object? - Hantex. - 01.07.2014

Problem solved! Thanks to all!