create_terrain {unifir}R Documentation

Create a terrain tile with optional image overlay

Description

Create a terrain tile with optional image overlay

Usage

create_terrain(
  script,
  method_name = NULL,
  heightmap_path,
  x_pos,
  z_pos,
  width,
  height,
  length,
  heightmap_resolution,
  texture_path = "",
  exec = TRUE
)

Arguments

script

A unifir_script object, created by make_script or returned by an ⁠add_prop_*⁠ function.

method_name

The internal name to use for the C# method created. Will be randomly generated if not set.

heightmap_path

The file path to the heightmap to import as terrain.

x_pos, z_pos

The position of the corner of the terrain.

width, height, length

The dimensions of the terrain tile, in linear units.

heightmap_resolution

The resolution of the heightmap image.

texture_path

Optional: the file path to the image to use as a terrain overlay.

exec

Logical: Should the C# method be included in the set executed by MainFunc?

See Also

Other props: add_default_player(), add_light(), add_prop(), add_texture(), import_asset(), instantiate_prefab(), load_png(), load_scene(), new_scene(), read_raw(), save_scene(), set_active_scene(), validate_path()

Examples

if (requireNamespace("terra", quietly = TRUE)) {
  raster <- tempfile(fileext = ".tiff")
  r <- terra::rast(matrix(rnorm(1000^2, mean = 100, sd = 20), 1000),
    extent = terra::ext(0, 1000, 0, 1000)
  )
  terra::writeRaster(r, raster)

  script <- make_script("example_script",
    unity = waiver()
  )
  create_terrain(
    script,
    heightmap_path = raster,
    x_pos = 0,
    z_pos = 0,
    width = 1000,
    height = terra::minmax(r)[[2]],
    length = 1000,
    heightmap_resolution = 1000
  )
}

[Package unifir version 0.2.4 Index]