I have object and position of this object stored in Vector3 variable
I have second Vector3 array
public Vector3[] four;
I need to find from array positions 4 closest vectors to the object and put them to the array four . Im thinking how to do it for few hours but i really dont know how. Please give me some ideas(Please in C#).
Here is a method to find the 4 closest. Cast a distance on each of the positions im a forloop and in the same loop figure out if its closer and if it is… Overwrite the previous vector. Make another variable called float fourDistances.
For(int i = 0; i < positions; i++)
{
float distance = Vector3.Distance(positions*, transform.position);*