Looping maps
Hi guys,
Still learning Unity but I’ve dabbled and studied enough to have basic understanding of it (and C# of course.) I’m working on a 2D top-down Zelda clone and I’d like to get some insight on how to do two (possibly related) things:
A “Lost Woods” type screen where it keeps repeating regardless of what direction you go in, with of course a certain set of directions that eventually leads outside of the screen.
Similarly, if I were to ever create, say, an overworld type of map that seamlessly repeats, such as when you’re navigating an airship in an RPG like Final Fantasy.
I don’t necessarily need code written out for me, I’m just trying to wrap my head around the concepts that would make these two features work.
Thanks!!
Posted Jan 27, 2022, 7:36 PM UTC
So for the Lost Woods, you could do it a few ways. One is you could actually just map out the scenes - even though they will "look" the same, it will still be the same logic as say any other map situation where you are switching rooms/screens/scenes. IMO that would be the easiest option by far.
Second option and probably unnecessarily complicated would be to have the scene reload the same exact scene every time you enter a "transition" point (ie leave the screen / hit a collider). You'll have an array of the "correct" directions (ie left, right, up, down), and then an empty list of your "chosen" directions (ie what the player does).
You could use an enum for this list & array. And then every time you leave the screen, it will add to the list your current choice/direction. If you get it wrong, the list resets (clear/delete). When the directions of the list match those of the array, you clear the screen.
This technique is useful for anything where the player needs to do a set of tasks to match something, ie hit a series of buttons, that type of thing. You have a reference array (the correct order), and then a list (or array) that continually saves the players choices (and resetting it back to 0 when they don't get it) until they get it right.
As for the airship, that's as simple as just having a scrolling parallax/background that repeats / loops.
Thank you so much for your input!! This is helpful.