- Home /
The question is answered, right answer was accepted
Terrain Tree Placing Not Working
I have a terrain in the game world. I go into placing trees mode with the Terrain Toolkit, and I make a new tree in there, using a prefab I made from a model. I select it and mouse over on the terrain. The blue circle is there, but when I click, nothing happens. Not a single tree gets placed. I go over to the console and it says:
The tree medium tree 1 couldn't be instanced because the prefab contains no valid mesh renderer UnityEditor.HostView:OnGUI()
The prefab already has a mesh renderer attached, so I have no idea what Unity is talking about.
Screenshots, if they help: http://i.imgur.com/EP20AE0.png http://i.imgur.com/IoeGjAT.png
Please help!
Answer by MrSoad · Nov 14, 2014 at 12:37 AM
Hello again, I've deleted my last answer etc as it was totally wrong. This issue was because your model was split into separate mesh objects, the terrain editor will not take them like that. I had no idea that it worked like this so we have both learnt something worthwhile :)
Here is a link to a version of you tree that will work properly :
https://www.dropbox.com/s/8by9zlwsjzv1sfl/New_Working_Tree.unitypackage?dl=0
When you drag it into the scene from a prefab it will be on its side and also be very small. The reason it is on its side is because of the way Blender handles the x,y,z axis, when you use this in the terrain editor it will be the right way up. The reason it is small is due to us swapping files between you 3D package and Blender(I think, I have had issues the same as this before when doing this). When you use it in the terrain editor it will be much bigger. I'm not sure I got the size adjusted right so change the "Scale Factor" setting in the Tree model import settings until it is the right size for you(do this when you have placed some via the terrain editor so you can see when it is right). I have added a collider, but this may or may not adapt correctly when you change the Scale Factor setting.
You may want to re do you model yourself now you know what the underlying issue was to fix the quirks that have been added by me using Blender. If you do then join your tree mesh objects together, remove doubles on the new whole mesh(you had a lot of duplicate verts, approx 200 in total), then unwrap and create a texture similar to the quick one I have made for you.
Hope you can move forward from here now :)
Thank you it is working, except for one little thing.
I scaled up the prefab and used it in the painting, but the trees still turn out very small. I tried messing with the parameters in the prefab and in the terrain but neither is affecting them. The console does say that they need a nature/soft occlusion shader, but I doubt that that's what's happening.
Did you change the Scale Factor of the original tree model in its import settings? Select your original tree model(not the prefab version) if the folder, then in the inspector window look for this setting and change it. This should hopefully work its way through onto your terrain.
The Nature Soft occlusion shader is for bill boarding to work properly(if i remember right). It should not affect anything else. You can change this by selecting a the correct shader from the drop down list on the tree material,
Ultimately you are probably better off redoing your original model via the method I describe above as this will sort out all these issues that I've unavoidably introduced. Now you know what the issue is you should be able to move through doing this with relative ease :)
Here is a pic of the trees on my terrain with the correct shader applied so that bill boarding works properly, you should be able to see where they change from 3D into 2D.
Three last things, if you do keep my version of your tree :
1) When you give it the "Nature/Tree Soft Occlusion Bark" shader turn the Amb. Occlusion setting right down or you will get an unwanted artifact on the tree texture.
2) In you model import setting set "Normals " to "Calculate", and set "Smoothing Angle" to 0.
3) When you have made changes to the material you will need to delete and re-add your tree prefab in your terrain for the changes to take effect.
Hopefully that is as much as you need to know :D
Here is a pic of the trees with these final changes in place :