Jump to content

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


maaxiim
Go to solution Solved by Peter,

Recommended Posts

Hello,

 

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:
image.png.965560b9780ce655247070706148c979.png

The flattener is configured as follows:
image.png.b856b1fc1613f39be6d20b3e421565a5.png

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:

image.png.34f5d83478c266774ba392237faf055b.png

When the runtime spawner spawns in to the scene, it is raising the terrain level much higher than the surrounding terrain:
image.thumb.png.924d409b97bccbb411e334306226db1a.png

 

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

Thanks

Oh, the logic I use to spawn the instance:
 

private void Spawn(GeNaRuntimeSpawner runtimeSpawner, UnityEngine.Terrain terrain)
        {
            runtimeSpawner._spawner.Load();

            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);

                runtimeSpawner._spawner.Spawn(randomPosition);
            }
        }

 

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...