- Home /
Scripts on Terrain Trees
I noticed that when my trees in my game have colliders, the framerate drops by something like 100 (the trees are part of the terrain). What I would like to do is to have the trees check the distance from the tree itself to any moving object, and if the object comes close to it, then turn on the collider, and if the object is farther away, turn it off. I tried attaching the script to the tree asset and then updating it in the terrain engine, but the script doesn't run. Is that because the trees aren't actually GameObjects? In that case, is it possible for me to:
Add a script to a terrain tree
Reduce overhead by disabling tree colliders
Thanks in advance!
Answer by brandonetter · Sep 05, 2012 at 06:13 AM
Hmm... well
http://docs.unity3d.com/Documentation/ScriptReference/TerrainData.html
You could get the location of the trees from here (pretty sure...I think). And then have OTHER game objects at those locations, and turn THEIR collision boxes on and off. Best I got. Good luck.
No that won't solve the problem, but thanks anyways. Thats good information to know in the long run though.
Answer by belede · Mar 05, 2020 at 07:12 PM
I have colliders on a terrain with a lot of terrain trees without frame rate drop. The best solution seems to put LODs on your trees with billboards and then culling as the distance grows. SpeedTrees include these functions, but you can make it with any custom tree by getting LOD and billboard (I use Amplify Impostor) tools from the asset store.