Hello ,
So i’m using this script from jc_lvngstn to replace the terrain trees by my choppable trees , however , i haven’t find a way to network this ,
Here’s the script :
TerrainData terrain = Terrain.activeTerrain.terrainData;
TreeInstance treeInstances = terrain.treeInstances;
float maxDistance = float.MaxValue;
Vector3 closestTreePosition = new Vector3();
int closestTreeIndex = 0;
for (int i = 0; i < treeInstances.Length; i++)
{
TreeInstance currentTree = treeInstances*;*
Vector3 currentTreeWorldPosition = Vector3.Scale(currentTree.position, terrain.size) + Terrain.activeTerrain.transform.position;
float distance = Vector3.Distance(currentTreeWorldPosition, hit.point);
if (distance < maxDistance)
{
maxDistance = distance;
closestTreeIndex = i;
closestTreePosition = currentTreeWorldPosition;
}
}
TreeInstances.RemoveAt(closestTreeIndex);
terrain.treeInstances = TreeInstances.ToArray();
float[,] heights = terrain.GetHeights(0, 0, 0, 0);
terrain.SetHeights(0, 0, heights);
Network.Instantiate(FallingTreePrefab, closestTreePosition, Quaternion.identity,1);
So , Of course , the falling tree instantiate but nothing happens to the tree , also i set this to RPC and called it , didn’t work
help would be appreciated
thanks