So I have this beautiful little C# script and I’d like to use it to generate 10 random points within 50 units of an object, which will then proced to travel between them. I’ve gotten up to the point where I need to check whether or not the points I generated are within 50 units of the object. In order to do this, I need to get the location of the object. I’ve checked the online scripting guide that Unity has, but I can’t seem to find it there. Could someone please help?
Here’s the code I have so far (this is all in the Update() method)
//variables to hold the x and y value of the point until I check to see if the point is within 50 units of my object
int xCord = 0, yCord = 0;
//array to hold the points I find are valid
int[,] listGather = new int[10, 2];
for( int x = 0; x < 10; x++ )
{
for( int y= 0; y < 2; y++ )
{
//generate random numbers between 1(inclusive) and 50(exclusive)
xCord = Random.Range(1, 50);
yCord = Random.Range(1, 50);
}
}