{"name":"setTerrainHeight","operator":null,"title":"setTerrainHeight","type":"command","url":"https://community.bistudio.com/wiki/setTerrainHeight","revid":377594,"updated":"2026-01-02T06:59:43Z","groups":["Positions"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.10"}],"since":{"game":"arma3","name":"Arma 3","version":"2.10"},"arma3_since":"2.10","branch":null,"locality":{"argument":null,"effect":"global","server_exec":true},"exec":null,"description":"Set the current terrain's altitude on provided location(s).\n\n> [!IMPORTANT]\n> - Heightmap changes:\n>   - are internally converted (rounded) to heightmap coordinates\n>   - are stored in the JIP queue\n>   - are **not** removed from the JIP queue if the values are set back to terrain's default value\n>   - are updated in the JIP queue for updated positions **if** the same group of positions are edited (order does not matter, but amount does);\n> editing positions by terrain *sections* is good for multiplayer optimisation (see #Example 2)\n>   - are **not** updated and sent twice (old one then new one) if position edits are not exactly the same (see point above and #Example 2).\n> - Edited terrain heights are **not** saved inside savegames, they need to be restored manually on savegame load.\n> - Known issues:\n>   - Terrain sections can become invisible if the change is too extreme\n>   - Walking on the edge of extreme height changes can catapult the player away","syntaxes":[{"syntax":"setTerrainHeight [positionAndAltitudeArray, adjustObjects]","since":null,"effect":null,"exec":null,"params":[{"name":"positionAndAltitudeArray","type":"Array of PositionASL","optional":false,"default":null,"description":"[[x1, y1, newASLHeight1], [x2, y2, newASLHeight2], ...]","types":["Array","PositionASL"],"since":null,"text":"positionAndAltitudeArray: Array of PositionASL - [[x1, y1, newASLHeight1], [x2, y2, newASLHeight2], ...]"},{"name":"adjustObjects","type":"Boolean","optional":true,"default":"true","description":"if true then objects on modified points are moved up/down to keep the same ATL height\n\n> [!IMPORTANT]\n> **All** objects above modified terrain will be adjusted, even flying ones.","types":["Boolean"],"since":null,"text":"adjustObjects: Boolean - (Optional, default true) if true then objects on modified points are moved up/down to keep the same ATL height\n\n> [!IMPORTANT]\n> **All** objects above modified terrain will be adjusted, even flying ones."}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"unary","operator":null,"left":null,"right":{"text":"[positionAndAltitudeArray, adjustObjects]","types":["Array"]}}],"examples":[{"text":"```sqf\nprivate _fnc_flattenTerrain =\n{\n    params [\"_start\", \"_a\", \"_b\", \"_h\"];\n    private _newPositions = [];\n\n    for \"_xStep\" from 0 to _a do\n    {\n        for \"_yStep\" from 0 to _b do\n        {\n            private _newHeight = _start vectorAdd [_xStep, _yStep, 0];\n            _newHeight set [2, _h];\n            _newPositions pushBack _newHeight;\n        };\n    };\n\n    _newPositions;\n};\n\nprivate _desiredTerrainHeight = 150;\nprivate _positionsAndHeights = [getPosWorld player, 50, 50, _desiredTerrainHeight] call _fnc_flattenTerrain;\nsetTerrainHeight [_positionsAndHeights, true];\n```","code":["private _fnc_flattenTerrain =\n{\n\tparams [\"_start\", \"_a\", \"_b\", \"_h\"];\n\tprivate _newPositions = [];\n\n\tfor \"_xStep\" from 0 to _a do\n\t{\n\t\tfor \"_yStep\" from 0 to _b do\n\t\t{\n\t\t\tprivate _newHeight = _start vectorAdd [_xStep, _yStep, 0];\n\t\t\t_newHeight set [2, _h];\n\t\t\t_newPositions pushBack _newHeight;\n\t\t};\n\t};\n\n\t_newPositions;\n};\n\nprivate _desiredTerrainHeight = 150;\nprivate _positionsAndHeights = [getPosWorld player, 50, 50, _desiredTerrainHeight] call _fnc_flattenTerrain;\nsetTerrainHeight [_positionsAndHeights, true];"]},{"text":"Bad example:\n\n```sqf\n// first update\nsetTerrainHeight [[[1000, 1000, 25], [1005, 1000, 25], [1000, 1005, 25], [1005, 1005, 25]]];\n\n// second update - this will make the JIP queue keep both messages\nsetTerrainHeight [[[1005, 1000, 50]]];\n```\n\nGood example:\n\n```sqf\n// first update\nsetTerrainHeight [[[1000, 1000, 25], [1005, 1000, 25], [1000, 1005, 25], [1005, 1005, 25]]];\n\n// second update - this will update the JIP queue properly\nsetTerrainHeight [[[1000, 1000, 25], [1005, 1000, 50], [1000, 1005, 25], [1005, 1005, 25]]];\n```","code":["// first update\nsetTerrainHeight [[[1000, 1000, 25], [1005, 1000, 25], [1000, 1005, 25], [1005, 1005, 25]]];\n\n// second update - this will make the JIP queue keep both messages\nsetTerrainHeight [[[1005, 1000, 50]]];","// first update\nsetTerrainHeight [[[1000, 1000, 25], [1005, 1000, 25], [1000, 1005, 25], [1005, 1005, 25]]];\n\n// second update - this will update the JIP queue properly\nsetTerrainHeight [[[1000, 1000, 25], [1005, 1000, 50], [1000, 1005, 25], [1005, 1005, 25]]];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["getTerrainInfo","getTerrainHeight"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Positions","Introduced with Arma 3 version 2.10","Scripting Commands","Scripting Commands: Global Effect","Scripting Commands: Server Execution"]}