[help] Calculate 10 closest objects from an array
#3

Quote:
Originally Posted by » RэРиR «
Quote:
Originally Posted by °ғαιιοцт°
I know how to calculate THE closest object but not how to calculate the 10 closest :l
Can you post that one please? Maybe I can help you.
loop trough all coordinates, and calculate the distance

if the distance is smaller than the previous distance, that object is closer
once you've looped trough all objects, the smallest one will be left :P (smallest distance)

here is some code for creating a closest object, it's from somewhere in my script :P for calculating closest objects

Код:
				new closest;
			  new dist = -1;
			  for(new o=0; o<21; o++)
			  {
			    new dist2 = distance(i, ClosestPlatform[o][0], ClosestPlatform[o][1], ClosestPlatform[o][2]);
			    if(dist2 < dist || dist == -1)
			    {
			      closest = o;
			      dist = dist2;
			    }
			  }
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)