0
\$\begingroup\$

I am making a multiplayer game in Unity, with a socket.io server in NodeJS. I am using a globe, with a texture to represent the world in Unity.

Let's say something similar do this.

https://cdnb.artstation.com/p/assets/images/images/003/013/353/large/paulsen-design-cartoon-low-poly-earth-24.jpg?1468495143

Now, there I am stuck with some algorithm.

I would like to generate equally distant point, on the lands, where user can build stuff.

Something similar to this : enter image description here

I saw this post here post and I would like to generate the map in the server, create from the generate map a mongoDB collection of point. When a user connect, he get back a list of point (that are already generated and can interact with those).

I get stuck on the generation. How do I make the server generate point based on a map that I will show to client, but that the server do not have idea of ? How would I store the coordinate position, so that the server generate them, and the client no matter the scale of the map would be able to display them at the good point ?

Basically, I don't know where to start to make this algorithm. I just would like some idea on how you would achieve this, so I can inspire myself to find my solution.

\$\endgroup\$
  • \$\begingroup\$ Can you clarify this: "How would I store the coordinate position, so that the server generate them, and the client no matter the scale of the map would be able to display them at the good point?" Presumably you're storing your points in absolute planet coordinates - like an x, y, z offset from the center of the globe in a reference orientation, or latitude/longitude(/altitude) - not screen coordinates depending on the client. So when drawing the points on your screen, you may apply view-dependent changes/scaling, but those never alter the underlying data. Have I misunderstood this scaling? \$\endgroup\$ – DMGregory Aug 24 at 14:26
  • \$\begingroup\$ No you right. The thing is, I am unsure of what format I should store the coordinate. Here I took the exemple of earth, but it will probably be a custom planet, I believe lat/long will always work no matter the planet and the scale since it's above surface and there will be no altitude, so it's a good idea to store the point coordinate in this format. The problem is still generating those point, It's the firststep yet the hardest cause I pretty much know how to implement the rest \$\endgroup\$ – Bobby Aug 24 at 15:40
  • 1
    \$\begingroup\$ Myself, I'd be tempted to apply a geodesic tesselation to the sphere, then take the resulting points and discard any that don't fall on land. You get good uniformity that way, across a controllable range of densities, but there is a risk of missing small islands/peninsulas, or having a poor fit to the coastlines compared to a method that starts from the land shapes and works in from there. If an approach like that would work for you, someone could expand on the details with an answer. Or, if that's not suitable, can you tell us more about what you need instead? \$\endgroup\$ – DMGregory Aug 24 at 15:46
  • \$\begingroup\$ Thank you for your reply. I do not need to be precise. Missing small island or having point not exactly on border is not a problem. I will probably adjust the amount of point very low at first since there will probably be not many player, and augment the density later on. As long as the point are equidistant and in line like the image above it will be good enough for me. The algorithm for point can be improved later anyway, but I am searching something to start with, concerning the detection of water/land. \$\endgroup\$ – Bobby Aug 24 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.