Search Unity

Terrain.SetNeighbors

Discussion in 'Editor & General Support' started by JRW_WSP, Jan 11, 2018.

  1. JRW_WSP

    JRW_WSP

    Joined:
    Jun 26, 2017
    Posts:
    37
    Hello community

    I've never really seen this answered anywhere and it certainly isn't answered in the Unity docs. I have a script I've written which I'm popping on each of my terrains to stitch them together (they already have right heights set this purely LOD matching).

    What I can't work out is what the "left", "top", "right" and "bottom" variables of Terrain.SetNeighbors() correspond to in Unity's world space. My assumption is "-x", "+z", "+x" and "-z" but lets, face it - Unity terrain can be very unintuitive, especially going from terrain coords to world so some kind of definitive information on this would be great!

    Cheers

    Num_T

    Edit: Nevermind found it...

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. public class LOESetNeighbors : MonoBehaviour
    4. {
    5.     public Terrain MinusXTerrain;
    6.     public Terrain PlusXTerrain;
    7.     public Terrain PlusZTerrain;
    8.     public Terrain MinusZTerrain;
    9.  
    10.     // Use this for initialization
    11.     void Start ()
    12.     {
    13.         Terrain thisTerrain = GetComponent<Terrain>();
    14.         thisTerrain.SetNeighbors(MinusXTerrain, PlusZTerrain, PlusXTerrain, MinusZTerrain);
    15.     }
    16. }
    17.