SA-MP Forums Archive
Best way to calculate space between objects - 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: Best way to calculate space between objects (/showthread.php?tid=635928)



Best way to calculate space between objects - Cypress - 16.06.2017

So lets say I want to create a set of objects in one line and leave the same space between them even if some objects are bigger and some are smaller they all will have the same distance between them.

Obviously one thing I would need to know is the size of the object but what do I have to do afterwards?


Re: Best way to calculate space between objects - Toroi - 16.06.2017

I'm not a math guy but if you have the size of the object wouldn't it be a simple point to point distance measurement and then substract the size of each object from that value?


Re: Best way to calculate space between objects - Cypress - 16.06.2017

Hmmm not sure. It's kinda a brain attack. Simple to make a line of objects but harder if there are different sized objects in that line coz the pos gonna change.


Re: Best way to calculate space between objects - JasonRiggs - 16.06.2017

Get the average size, and consider that all the objects are with that size, and calculate the distance you want between these objects


Re: Best way to calculate space between objects - Marricio - 16.06.2017

If its a low amount of objects, you could set up the distance for each object yourself in an array. However, if its a complex set of objects I would recommend you to obtain the collision size with Y_Less include, then add a default minimum distance and you're ready to go. It's not really going to be very exact, but you're going to get good results.


Re: Best way to calculate space between objects - Sew_Sumi - 16.06.2017

Someone made an include showing how big certain vehicles were, could be time to have one for objects as well.


Re: Best way to calculate space between objects - CheezIt - 16.06.2017

https://sampforum.blast.hk/showthread.php?tid=570965

Then do something similar to the GetXYInFrontOfPlayer function (you may need to do an adjustment depending on the direction).