- Home /
Dealing with placing large amounts of objects via script?
Ok so I got pretty tired of trying to use the terrainData to place trees and rocks, so instead I opted to make a separate script that will do that for me... Which will give me some more freedoms and options for the said objects. Like destroying them on contact.
So what I have now are some objects(prefabs) like rocks that get instantiated at various positions on a VERY, VERY LARGE MAP...(That gets cut up into different neighbors). The objects also have 3 level LODS on them, but there has to be a massive amount of them and I don't want the whole scene in the editor clogged up with thousands of such things. So how would I go about minimizing this?
Also, is it still worse than using the terrainData detail meshes way? How much worse? IS there a way to make it similar?
My game WIP thread: http://forum.unity3d.com/threads/omega-void-wip.200629/
Answer by jmgek · Dec 23, 2014 at 09:16 PM
"Which will give me some more freedoms and options for the said objects. Like destroying them on contact." I don't know what you mean by this but I think you are talking about procedurally placing objects, this is very easy, either ray cast a position on your map that will instance a object on the map or do it though a height map.
"So how would I go about minimizing this?" If I understand your question. I hate making prefabs and muddling up my editor. So I make a new parent in code and parent it to hold all the new objects.
objectHolder= new GameObject("Scene Object Holder");
rockobject.transform.parent = objectHolder.transform; //This childs whatever object you want to a new game object.
Yeah thanks, I was thinking of doing that, but is it ok performance wise? That was my gripe. Is it worse or better than the other way using the terrain tool?
Well personally don't like using the terrain tool. It is pretty expensive and just to have it in gameis a very large thing. unless you are using height maps, but that is a whole other story. As for me I don't like to manually do anything, I create systems for generation but placing objects on a terrain is harder than instancing on a perimative object, you have to deal with height and where they will be placed on your terrain. You do give yourself more control over placment so it looks more natural but if you are able to create a system that can do this you can always sell it as a tool.
Just to put it in perspective, I deal with tessliation as well as height maps for generation, I have been working on a system that builds lands for about a month and it is hard work. If this is the main mechanic of your game go for it but if it is just a side thing just use the terrain builder and get a level designer.
What other option are you thinking of using? I don't know what you are trying to compaire the terrain to. Are you talking about just using planes?
Your answer
Follow this Question
Related Questions
Instantiated Objects not being set at ground/terrain level?(Solved) 1 Answer
Replace GameObject vs. replacing mesh and material? 2 Answers
Unwanted 2nd empty gameobject 1 Answer
Every NetworkViewID is 0? 0 Answers
NavMesh giving jerky like motion 0 Answers