Quantcast
Channel: Questions in topic: "crash"
Viewing all articles
Browse latest Browse all 2383

Terrain addTreeInstance crash

$
0
0
I seem to have a problem with creating trees on a terrain object using terrain.AddTreeInstance(instance); function because it crashes unity on play. I got multiple terrain objects generating at runtime and I'm trying to add one tree to the corner of each terrain with this code: NOTE: I'm creating the trees before actually setting the terrainData to the terrain so it does update the terrain after my trees get added. var tmp : TreeInstance = new TreeInstance(); tmp.heightScale = 1.0f; tmp.widthScale = 1.0f; tmp.prototypeIndex = 0; tmp.color = Color.white; tmp.position = new Vector3(0.0f,heightMap[0,0],0.0f); terrain.AddTreeInstance(tmp); Also I have added one tree prefab to the treeprototypes array earlier in the code and it does show up in the inspector if I do not create trees this way. Does anyone else experience this or am I using the AddTreeInstance function wrong?

Viewing all articles
Browse latest Browse all 2383

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>