# STerrain

**Members** 10

|          |                               |                                                                         |
| -------- | ----------------------------- | ----------------------------------------------------------------------- |
| Function | [GetHeight](#getheight)       | Get an interpolated height at a point x,y.                              |
| Function | [GetSteepness](#getsteepness) | Get the gradient of the terrain at point (x,y).                         |
| Function | [GetHeights](#getheights)     | Returns a two dimensional array of heightmap samples.                   |
| Function | [SetHeights](#setheights)     | Sets heightmap data using a two dimensional array of heightmap samples. |
| Function | [SetHeight](#setheight)       | Set value to height of \[x,y]                                           |
| Function | [GetNormal](#getnormal)       | Get an interpolated normal at a given location.                         |
| Function | [GetSlope](#getslope)         | Get a normalized and interpolated normal at a given location.           |
| Function | [GetContour](#getcontour)     | Get a contour of interpolated normal at a given location.               |
| Property | [Enabled](#enabled)           | Is the Terrain component enabled?                                       |
| Property | [GameObject](#gameobject)     | The GameObject that this Terrain component is added to.                 |

## Functions

### GetHeight

float GetHeight(float x, float y)

Get an interpolated height at a point x,y.

Parameters

| Name | Type  | Default |
| ---- | ----- | ------- |
| x    | float | –       |
| y    | float | –       |

Returns

`float`

Example

**Lua**

```lua
floatHeight = Space.Host.ExecutingObject.Terrain.GetHeight(1,1)

```

### GetSteepness

float GetSteepness(float x, float y)

Get the gradient of the terrain at point (x,y).

Parameters

| Name | Type  | Default |
| ---- | ----- | ------- |
| x    | float | –       |
| y    | float | –       |

Returns

`float`

Example

**Lua**

```lua
floatSteepness = Space.Host.ExecutingObject.Terrain.GetSteepness(1,1)

```

### GetHeights

float\[,] GetHeights()

Returns a two dimensional array of heightmap samples. The samples are represented as float values ranging from 0 to 1. The array has the dimensions \[height,width] and is indexed as \[y,x].

Returns

`float[,]`

Example

**Lua**

```lua
tableHeights = Space.Host.ExecutingObject.Terrain.GetHeights()

```

### SetHeights

void SetHeights(float\[,] data)

Sets heightmap data using a two dimensional array of heightmap samples. The samples are represented as float values ranging from 0 to 1. The heights array is indexed as \[y,x].

Parameters

| Name | Type      | Default |
| ---- | --------- | ------- |
| data | float\[,] | –       |

Returns

`void`

Example

**Lua**

```lua
tableHeights = Space.Host.ExecutingObject.Terrain.SetHeights({{1,2},{1,2}})

```

### SetHeight

void SetHeight(int x, int y, float value)

Set value to height of \[x,y]

Parameters

| Name  | Type  | Default |
| ----- | ----- | ------- |
| x     | int   | –       |
| y     | int   | –       |
| value | float | –       |

Returns

`void`

Example

**Lua**

```lua
Space.Host.ExecutingObject.Terrain.SetHeight(1,1,0.11) 

```

### GetNormal

[SVector](/docs/scripting/client-scripting-api-reference/types/svector.md) GetNormal(float x, float y)

Get an interpolated normal at a given location.

Parameters

| Name | Type  | Default |
| ---- | ----- | ------- |
| x    | float | –       |
| y    | float | –       |

Returns

`SVector`

Example

**Lua**

```lua
vectorNormal = Space.Host.ExecutingObject.Terrain.GetNormal(1,1)

```

### GetSlope

[SVector](/docs/scripting/client-scripting-api-reference/types/svector.md) GetSlope(float x, float y)

Get a normalized and interpolated normal at a given location.

Parameters

| Name | Type  | Default |
| ---- | ----- | ------- |
| x    | float | –       |
| y    | float | –       |

Returns

`SVector`

Example

**Lua**

```lua
vectorSlope = Space.Host.ExecutingObject.Terrain.GetSlope(1,1)

```

### GetContour

[SVector](/docs/scripting/client-scripting-api-reference/types/svector.md) GetContour(float x, float y)

Get a contour of interpolated normal at a given location.

Parameters

| Name | Type  | Default |
| ---- | ----- | ------- |
| x    | float | –       |
| y    | float | –       |

Returns

`SVector`

Example

**Lua**

```lua
vectorContour = Space.Host.ExecutingObject.Terrain.GetContour(1,1)

```

## Properties

### Enabled

bool Enabled {get; set; }

Is the Terrain component enabled?

Example

**Lua**

```lua
Space.Host.ExecutingObject.Terrain.Enabled = false

```

### GameObject

[SGameObject](/docs/scripting/client-scripting-api-reference/types/sgameobject.md) GameObject {get; }

The GameObject that this Terrain component is added to.

Example

**Lua**

```lua
theGameObject = Space.Host.ExecutingObject.Terrain.GameObject

```
