Hi, following on from my recent post requesting help about fish location/coordinates which produced a great solution by the pros (im a beginner)…
I now need to specify a specific area/size of the area the fish will flock within.
eg: The code below has a TankSize which is bsaically square and so fish go through the floor and out of the water which I solved by reducing the TankSize.
However, I would like to specify a more specific TankSize to avoid this.
Here is the current code which specifies a square area (I believe?)…
public static int tankSize = 35;
static int numFish = 250;
public static GameObject[] allFish = new GameObject[numFish];
public static Vector3 goalPos = genfishglobalFlock.goalPos;
// Use this for initialization
void Start()
{
for (int i = 0; i < numFish; i++)
{
Vector3 pos = this.transform.position +
new Vector3(Random.Range(-tankSize, tankSize),
Random.Range(-tankSize, tankSize),
Random.Range(-tankSize, tankSize));
allFish[i] = (GameObject)Instantiate(fishPrefab, pos,
Quaternion.identity);
The exact coordinates of those fish is: -2147f, 15f, 465f
Basically the sea level is 50 and so a tank size of 35 is kinda too large as the fish dissapear below the terrain or above the sea level so in the current settings have opted for below the map/terrain.
Is there a way to specify x y and z for the tank size?
As I write this I am having the idea of instead of using 35 as the tank size use something like: x=55,y=20,z=55 but that actually doesnt work as you no doubt know.
Anyways, I appreaciate any guidance to solve the issue. Many thanks.
PS; I like to get my hands a little dirty to get some ideas before reading massive amounts of text and so will study these areas more when I get to see live examples of how this C# stuff works.
I have only just started to learn so please make any responses understandable to a newbie. Many thanks. Have a good one.[/CODE]