Random points relative to the the position, like Perlin Noise

Hello guys. I would to generate some random points relative to player position until i reach the limit to give the impression of having a huge map.

For example, Th red point is the player and the square follows him. I only want to generate the points in the radius of my orange square whatever the player position is. ( Something like that

It generate new points in a radius but keep the already generated points. I think it use a kind of seed.

I think it’s very similar to what the perlin noise do but i already seen this kind of algorithm long time ago but just don’t remember the name.

And i would like the algorithm to do this generation in a range of 500 for example and have the circle border after.

N.B : I can’t just set the player position as a seed because if i just move from one in the Z-axis the points which are already in the orange square will disappear replaced by another.

My code if someone want to do some else. ( Not tried but just need to edit angle and distance to only have the border )

Random.InitState(007);
      
        for (int i = 0; i < nbPTS; i++)
        {
            GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            obj.transform.localScale = new Vector3(7,7,7);

            float dist = Random.Range(0, range);

            float angle = Random.Range(0, 2 * Mathf.PI);

            Color color = Random.ColorHSV();

            Vector3 pos = new Vector3( dist * Mathf.Cos(angle), 0, dist * Mathf.Sin(angle));
          
            obj.transform.position = pos;
            obj.GetComponent<Renderer>().material.color = color;

            obj.name = i.ToString();
            print($"Angle {i} : {angle}");



        }

You want to “hash” the space coordinate into cells, then use the concatenate coordinate of a cell as a seed to the random function, then generate as many needed element in that cells. You should probably use a random hash because contiguous seed of typical random function aren’t random.

1 Like

Okey, thank’s for answer ! I also remember the name waht i was looking for. Octree…