TreeInstance не все параметры применяются, во время высадки деревьев

Я задаю рандомные значения heightScale,rotation у TreeInstance. Но деревья высаживаются без рандома в высоте и повороте : введите сюда описание изображения Почему ?

Мой метод PlaceTree :

public static void PlaceTree(Terrain terrain, int treePrototype, Vector3 position, Color color, float rotation, float height = 1.0f, float width = 1.0f)
    {
        TreeInstance instance = new TreeInstance();
        instance.position = position;
        instance.color = color;
        instance.lightmapColor = Color.white;
        instance.prototypeIndex = treePrototype;
        //Debug.Log("height="+height);
        instance.heightScale = height;
        instance.widthScale = 1.0f;
        //Debug.Log("rotation="+rotation);
        instance.rotation = rotation;
        terrain.AddTreeInstance(instance);
        // terrain.Flush();
    }

Метод DrawTree , который вызывает PlaceTree и задаёт рандомные значения :

    static public void DrawTree(List<Terrain> terrains, List<Vector3> drawcord, List<PrefabSelectionMenu.Prefab> m_ListPrefabsTree) {
            foreach (var pos in drawcord)
            {
                foreach (var terrain in terrains) {
                    if (pos.x >= terrain.GetPosition ().x && pos.x <= terrain.GetPosition ().x + terrain.terrainData.size.x &&
                        pos.z >= terrain.GetPosition ().z && pos.z <= terrain.GetPosition ().z + terrain.terrainData.size.z)
                    {

                        int random_int = UnityEngine.Random.Range (0, m_ListPrefabsTree.Count);

                        int angle = 0;
                        if(m_ListPrefabsTree[random_int].randRotToggle == true) {
                            if(m_ListPrefabsTree[random_int].randRotXYZ[1] != false) {
                                angle = 360;
                            }
                        }
                        angle = UnityEngine.Random.Range (0, angle);
                        double radangle = ((double)angle* (Math.PI/180));
                        //Debug.Log("angle="+angle+" radangle="+radangle);

                        float widthheightTree = UnityEngine.Random.Range (m_ListPrefabsTree[random_int].randScaleMin, m_ListPrefabsTree[random_int].randScaleMax);
                        Vector3 position = new Vector3((pos.x- terrain.GetPosition ().x) / terrain.terrainData.size.x,0,(pos.z - terrain.GetPosition ().z) / terrain.terrainData.size.z);
                        position = new Vector3(position.x,terrain.SampleHeight(position),position.z);

                        float height = 1.0f;
                        if (m_ListPrefabsTree[random_int].randScaleToggle)
                            height = UnityEngine.Random.Range(m_ListPrefabsTree[random_int].randScaleMin, m_ListPrefabsTree[random_int].randScaleMax);

                        // position += position * m_ListPrefabsTree[random_int].depth*position.y;
                        // Terrain terrain, int treePrototype, Vector3 position, Color color, float height, float width, float rotation
                        PlaceTree (terrain,
                                        m_ListPrefabsTree[random_int].idPrefabTarrainData,
                                        position,
                                        Color.green,
                                        (float) radangle,
                                        height);
                    }
                }
            }
    }

Ответы (0 шт):