- Home /
Best way to paint gameobjects on a terrain?
So, I've made quite a few prefabs of trees and vegetation for my game and now its time to actually place them on the terrain in large quantities. The prefabs I've made aren't anything like the unity trees and vegetation, so I've been unable to use the default terrain tree paintbrush with them. My question is, what would be the best way to place these custom gameObjects on the terrain so that they line up to the ground and can be painted on easily. What would be the most efficient way to solve this problem?
Answer by GoldGamerGod · Jul 29, 2013 at 05:22 AM
If you mean what I think you mean,you want Detail painting. First thing first,if you modeled the asset yourself,make sure the Y axis is up,since Unity follows Y as up. Then drag your mesh onto the scene and texture it. Then just create a prefab of what you want in assets and drag the mesh/object you have on scene onto the prefab. Next click terrain,go to Detail Objects,and select the prefab. Adjust the settings to your liking,same with how much you place,the brush,etc... Then click on the terrain to paint that object!
PS - I've not yet sure how to use physics on a detail object,but i'm pretty sure all you do is have the Collider you want in the prefab,and it'll work.
Well, thanks for your answer. But this wasn't my problem. I can use unity's default detail painting tool for my objects, but it doesn't show them correctly. Unity seems to add a bunch of features to whatever you paint on because that is how they think the detail painting should be treated. For example when I give the detail painting my gameObject, it changes the size, filter type, and removes the script which I needed on it. It seems to me that unity's paint detail tool is only good for simple mesh and texture objects. What I'm trying to paint on the screen is a 2d mesh and texture that will rotate to face the player wherever he is. What I need is a tool to add the prefab of this object that I already made and just place them in large amounts on the terrain without modifying the gameObject at all. It seems like there isn't an easy way to do this, so I'd like to get into unity's code and change how painting gameobjects work, but I can't figure out how to access their terrain script. Any advice?
Ah, so mainly you'ed like BillBoarding objects... I'm not sure on how you would do this. All I know is about the scale size is you need to CHANGE the scale size in the mesh options, not the transforms. Sorry couldn't have been much of help on this.
Answer by chummscrubber · Jul 29, 2013 at 04:29 AM
I have an idea on how to get them placed correctly, but not how to paint them. Basically create an empty game object and set it as the parent of each different tree prefab at the location of where you want the tree to clip the terrain.
Then use code to check the terrain height at the location you want to place the tree/s at, then set the position of the empty game object to the terrain height, since it is the parent this will move the tree into position nicely.
Answer by raphu604 · Jan 28, 2014 at 01:08 AM
You can try my asset MeshBrush on the store, it does exactly what you are looking for: https://www.assetstore.unity3d.com/#/content/14453
Your answer
Follow this Question
Related Questions
Terrain Brush Problem 2 Answers
Edit Terrain Script 0 Answers
Terrain brushes cannot be set - BUG 1 Answer
[Blender] Sculpt high detail with custom brush over low poly terrain 0 Answers
I can't add grass on my terrain 3 Answers