Community Forum

Place objects at terrain height - placeObjectsOnTerrain?

Forum Overview >> Editor

CategoryEditor
Created21.07.2021 18:42


Cory Rentz (coryrentz) 21.07.2021 18:42
Is there a way to place a selection of items at their locations terrain height? I have a mod map where the creator placed a large number of trees below the terrain level. I'd like to bring them all to the terrain height. Obvioulsy doing this manually would take more time than it's worth.

I was hoping the "placeObjectsOnTerrain" script would do this. However, I keep getting the following error in the console:
------------------------------------------------------------------------
Warning (script): Entity 'oak_stage4' has invalid type in method 'getTerrainHeightAtWorldPos'.
LUA call stack:
=C:/Program Files/GIANTS Software/GIANTS_Editor_8.2.2_64-bit/scripts/terrain/placeObjectsOnTerrain.lua (25) : getTerrainHeightAtWorldPos
Error: C:/Program Files/GIANTS Software/GIANTS_Editor_8.2.2_64-bit/scripts/terrain/placeObjectsOnTerrain.lua:26: bad argument #2 to 'format' (number expected, got nil)
------------------------------------------------------------------------

I did verify that all the variables up to that point do work. So I'm not sure what "nil" value the getTerrainHeightAtWorldPos script is getting.
terrain id == 76270 name == oak_stage4
id == 76234 name == oak_stage4
x=-2042.989868 y=75.052269 z=-1044.556885

Cory Rentz (coryrentz) 21.07.2021 22:26
I was able to partially solve my problem.
The script is looking for the TERRAIN ID, but if the terrain is not selected in your group then it won't find it. "local mTerrainID = getSelection( getNumSelected() - 1 );" I manually put in my terrain ID and it worked. I'm not sure how this script is supposed to work otherwise.

The next thing I need to figure out is how to loop through all the different transform groups. Right now I have to select the trees in the transform group - there's A LOT of these. I'd rather just select all the groups and have the script loop through the individual trees.



Note: Log in to post. Create a new account here.