- Home /
Terrains can't share terrain data?
So, I've been pulling my hair out because when I package up terrain data from my server and send it to the client, the client recreates everything except the tree colliders. I use the CreateTerrainGameObject function to create the terrain from the terrain data, but nothing I have tried gets the terrain collider to take the trees into account.
So, I've tried a different tactic. Let's say in my server scene, it has the terrains with the terrain data. So I have a TerrainData 0,1 prefab/gameobject store in my project. Great...so I'll just create an empty terrain with the correct terrain resolution in the CLIENT scene, and drag the TerrainData 0,1 terraindata to that terrain. Annnd nothing. I expected the client terrain to match the server one. Wrong. Zip, nada. You can test this by create two scenes, a server and a client. Create a terrain on the server, and see the new TerrainData stored in your projects.
Create a terrain in the client scene, and drag the terraindata from your project to the client terrain. You would expect them to match...but they DONT. According to the documentation, the terrain data stores the height information. But I can't get that to take effect when I assign it to a terrain.
This is maddening.
Answer by jc_lvngstn · Dec 15, 2011 at 02:34 PM
I found a solution for this. The world is broken up into terrains on the server, and the client only displays 4 terrains at a time (around the player). The solution was to go ahead and create 4 terrains on the client, using the terraindata defined in the project (which is also used by the server). I made sure the client terrains had the same resolution. When the server sent over the terrain data, I just refreshed/replaced the client terrain data with the stuff sent from the server. As a bonus...this took care of the terrain collider not creating colliders for the trees on the client side.