3
\$\begingroup\$

I have made an algorithm for procedurally generating a 2D tile map in Unity.

The player can use the mouse to pan the view and look at the map.

My intention was that when the player reaches one of the sides of the map, he would simply see the other side as if he was going around the Earth so to speak. a rectangular world map with a curved arrow from the right to the left edge

The only way I have achieved this is by simply instantly setting the camera's position to the other side of the map when the player crosses one of the edges. The problem with this is that the player never actually sees the "border" connection continuously and that bothers me since I took the care to generate the map in such a way that connecting the east/west edges makes sense.

How can I achieve the desired effect?

\$\endgroup\$
1

1 Answer 1

1
\$\begingroup\$

How about this:

You can count how many tiles the player can see when standing on the border (lets say they can see 5 more tiles).

In that case, each tile should know it's position in the array. If it is within the 5 tiles proximity of the border, it can make a copy of itself on the other side.

Lets say you are exactly on the right border. You want to see the 5 tiles most to the left... so each tile with x < 5 should create a purely visual copy on the right?

\$\endgroup\$
4
  • \$\begingroup\$ I had considered doing something like this possibly using auxiliary cameras ... I will give it a try \$\endgroup\$
    – Zeus_Ammon
    Apr 2, 2019 at 22:58
  • \$\begingroup\$ The only other way I can think of, is to actually roll the tiles around a cylinder - but that seems like it would be more effort, plus it could only work on one axis at a time. If your hero went to the corner of the map, you couldn't do it... \$\endgroup\$
    – lilKriT
    Apr 3, 2019 at 2:33
  • 1
    \$\begingroup\$ @lilKriT If you need it to 'roll' across both the X & Y axis, the shape you want is a torus, not a cylinder. \$\endgroup\$
    – Pikalek
    Apr 8, 2019 at 16:07
  • \$\begingroup\$ I hope this answers the orignal poster :D \$\endgroup\$
    – lilKriT
    Apr 8, 2019 at 16:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .