I’m using GetHeights and SetHeights to alter the terrain at run time. I only change 1 height at once, but i’m still getting a massive stutter when I use SetHeights.
I don’t have any trees or grass on the terrain, it’s purely terrain at this point.
My terrain is fairly large, so I assume it’s because it’s recalculating the collision mesh?
Is there any way of reducing the stutter or is this simply something I have to live with?
Go into Set Resolution which is under terrain and lower the the terrain width and length. This will cause the terrain to be smaller. This should help this problem. Or you could just make the graphic quality less so it will run faster.
If you had multiple smaller terrains, you'd have a hard time making sure the edges stayed aligned. As far as I can tell, SetHeights is recalculating the entire terrain mesh- so no, there isn't really a way to speed it up, unfortunately. Could you do some crazy LOD thing where the terrain gets more detailed if your computers are faster, or am I talking out of my bum about things I don't really understand?
The Unity docs say “The area affected is defined by the array dimensions and starts at xBase and yBase. The heights array is indexed as [y,x].” This means you can directly address the nodes you are altering without accessing any others. Simply use the first 2 values in the setHeights function as the starting point for the area you want to alter, and then the size of the array defines the ending point. I saved 40 FPS when I changed my code to this.
If you had multiple smaller terrains, you'd have a hard time making sure the edges stayed aligned. As far as I can tell, SetHeights is recalculating the entire terrain mesh- so no, there isn't really a way to speed it up, unfortunately. Could you do some crazy LOD thing where the terrain gets more detailed if your computers are faster, or am I talking out of my bum about things I don't really understand?
– syclamothWell from the looks of it, having multiple smaller terrains is the only practical solution here.
– syclamoth