- Home /
What is the best way to add 1000 sprite-trees?
Situation: - I'm currently using 2d sprites in a 3d environment. (- worldsize is 1000x, 1000z)
Problem: I'm trying to add trees (2d sprites) to my world, I need to create forests but I'm under the impression that creating a seperate gameobject for each spritetree is not very optimal?
Is it possible to combine these sprites into 1 mesh? If yes, how is the best way to achieve this?
Answer by rubenedra · Apr 24, 2014 at 12:01 PM
After a long search I finally got the answer:
You can't combine spriterenderers
But you can use a meshcomponent where you add your sprite as a texture multiple times
example code can be found here: http://forum.unity3d.com/threads/240750-2D-Efficiency-With-Sprites-and-Game-Objects?p=1603147#post1603147
Answer by koray1396 · Apr 18, 2014 at 04:59 PM
well, this is my opinion, but if i were you i would divide the whole area to regions, size depending on how much of it you show at max, let's say it's 50x50. on awake or start, you would instantiate the sprites (trees and others also) and add them as children to gameobjects for different regions. then, you would set them active, when you are near the regions, say, always 9 regions would be active, the one on screen and other 8 around. you would set them active or inactive easily with position, camera etc... by script. 1000 objects is not really too much, especially for sprites, as long as you keep them organized.
don't starve kinda thing? :)
good luck.
thx, nice solution! So I guess combining sprites is not an option?