- Home /
How do I go about creating a 2D world?
Hello,
I have made this grass image (resolution 64x64) which I plan to create an open world 2D game for a player to explore around. The design is for the ground which the player can walk around (with the camera as a bird's eye view) whilst exploring. I would like to know how to use that grass image to create the world for the player to stand on and walk around on.
Thank you so much for your time!
Answer by Bunny83 · Mar 27, 2018 at 08:32 PM
Any object that is derived from UnityEngine.Object can be duplicated with Instantiate. This will create an exact duplicate of the source object. This does work with Texture2Ds, Meshes, AnimationClips, GameObjects and ScriptableObjects.
Keep in mind that all those objects once duplicated have to be destroyed when you don't use them anymore. Objects which do not have any reference to them anymore are usually unloaded when you change scenes or call Resources.UnloadUnusedAssets.
However I'm not sure if you actually want to duplicate the texture itself. Note that a texture is just an data object. A texture may be used by material of objects or as sprites which are used by sprite renderers. If you just want to have the same image multiple times on screen you do not need (and do not want) to duplicate the texture nor the material or sprite. Though your question isn't very clear about your intentions. You just asked how to duplicate textures.
Your second question (which btw should have been a seperate question. One question per question plz) is even more confusing and unclear. You probably talk about a 2D game? If you use the latest Unity version you can use a Tilemap. Just check out the subtopics of Tilemap in the manual.
Infinite worlds is a topic on it's own. Infinite worlds is more about dynamic loading and unloading, dtoring the world on disk and usually about procedual generation. Though this highly depends on what kind of game you have in mind (top down, side scroller).
Sorry about that! Will put up the other question separately :)