> For the complete documentation index, see [llms.txt](https://sneakyevil.gitbook.io/sleeping-dogs-de-script-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sneakyevil.gitbook.io/sleeping-dogs-de-script-api/game-classes/simobject.md).

# SimObject

General game-object.

### Examples:

#### Objects Iteration:

```squirrel
for (local i = SimObject.GetHead(); i; i = i.GetNext())
{
    // Do something...
}
```

### Properties:

### Static Functions:

#### .Create

`SimObject.Create(model: Hash, coords: Vector3, rotation: Vector3)`: SimObject

| Argument | Type    | Description            |
| -------- | ------- | ---------------------- |
| model    | Hash    | -                      |
| coords   | Vector3 | Position of new Object |
| rotation | Vector3 | Rotation of new Object |

Returns SimObject when successfully created.

#### .GetHead

`SimObject.GetHead()`: SimObject

Returns first SimObject in ObjectsTree.

#### .GetNext

`SimObject.GetNext()`: SimObject

Returns next SimObject from ObjectsTree.

### Functions:

#### .SetDestroyOnUnload

`SimObject.SetDestroyOnUnload(toggle: boolean)`

| Argument | Type    | Description |
| -------- | ------- | ----------- |
| toggle   | boolean | -           |

You can toggle if the current SimObject should be destroyed when script gets unloaded.

{% hint style="info" %}
When you create any SimObject by default it will be set to be destroyed on unload, but you can override it by calling this function with toggle value to false.
{% endhint %}

#### .Destroy

`SimObject.Destroy()`

Destroys a SimObject. Please note `SimObject` will not become null.

#### .Restore

`SimObject.Restore()`

Restores all suspended components.

#### .Suspend

`SimObject.Suspend()`

Suspends all components. Note: some certain Objects will need to be suspend each [OnGameUpdate](/sleeping-dogs-de-script-api/callbacks/ongameupdate.md).

#### .GetName

`SimObject.GetName()`: Hash

Returns a SimObject name as hash.

#### .GetPropertyName

`SimObject.GetPropertyName()`: Hash

Returns a SimObject property name as hash, this is basically the model hash you use for creating SimObject.

#### .GetType

`SimObject:GetType()`: [SimObjectType](/sleeping-dogs-de-script-api/enums.md#simobjecttype)

#### .GetPosition

`SimObject.GetPosition()`: Vector3

#### .SetPosition

`SimObject.SetPosition(coords: Vector3)`

| Argument | Type    | Description       |
| -------- | ------- | ----------------- |
| coords   | Vector3 | World coordinates |

#### .GetRotation

`SimObject.GetRotation()`: Vector3

#### .SetRotation

`SimObject.SetRotation(euler: Vector3)`

| Argument | Type    | Description       |
| -------- | ------- | ----------------- |
| euler    | Vector3 | Rotation in euler |

### Attachment Functions:

#### .GetAttachmentCount

`SimObject.GetAttachmentCount()`: integer

Returns count of attached SimObjects to current SimObject.

#### .GetAttachments

`SimObject.GetAttachments()`: array\[SimObject]

Returns array of SimObjects that are attached to current SimObject.
