Jump to content

How adjust Flattener Y height so that it is more closely aligned with surrounding terrain.

Go to solution Solved by Peter,

Recommended Posts



I am using a GeNaSpawner to procedurally generate a scene. I am using a spawner that spawns a single prefab, inside of which is a flattener followed by 2 buildings. The hierarchy of the spawn prefab is as follows:

The flattener is configured as follows:

The batch root has an unpacker on it and is position 0,0,0 scale 1,1,1

Each of the building prefabs contains the following setup:


When the runtime spawner spawns in to the scene, it is raising the terrain level much higher than the surrounding terrain:


Am I missing a configuration setting in the spawner or on the flattener?


Oh, the logic I use to spawn the instance:

private void Spawn(GeNaRuntimeSpawner runtimeSpawner, UnityEngine.Terrain terrain)

            var terrainData = terrain.terrainData;
            for (int i = 0; i < runtimeSpawner._spawnAmount; i++)
                Vector3 randomPosition = terrainData.bounds.center +
                                         Random.insideUnitSphere * runtimeSpawner._spawnRadius;
                randomPosition.y = terrain.terrainData.GetHeight((int)randomPosition.x, (int)randomPosition.y);



Link to comment
Share on other sites

  • Solution

Hi @maaxiim,

when you drag and drop one of those prefabs with the flattener on it in the scene view, and you select the object / child that has the flattener on it, does the visualization show the same offset as well? Or is this something that is only introduced during the runtime spawning?
Two reasons I know that might cause this:

- The object holding the flattener decorator is a child that has an offset against the parent transform on the y-axis

- The terrain is not aligned at y=0

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Tell a friend

    Love Canopy - Procedural Worlds? Tell a friend!
  • Need help?

    We work with some of the biggest brands in global gaming, automotive, technology, and government to create environments, games, simulations, and product launches for desktop, mobile, and VR.

    Our unique expertise and technology enable us to deliver solutions that look and run better at a fraction of the time and cost of a typical project.

    Check out some of our non-NDA work in the Gallery, and then Contact Us to accelerate your next project!

  • Create New...