sm.unit
Associated object type: Unit
Unit creation and management
Functions:
sm.unit.createUnit(uuid, feetPos, yaw?, data?, pitch?, visible?)
Server only
Creates a new unit of type from an Uuid
Parameters:
| Type | Name | Description |
|---|---|---|
| Uuid | uuid | The character type uuid. |
| Vec3 | feetPos | The feet position in world where unit should spawn. |
| number | yaw? | The initial yaw. Defaults to 0 (Optional) |
| any | data? | The param data. (Optional) |
| number | pitch? | The initial pitch. Defaults to 0 (Optional) |
| boolean | visible? | Whether the unit is visible on spawn. Defaults to true. (Optional) |
Returns:
| Type | Description |
|---|---|
| Unit | The created unit. |
sm.unit.forceDestroy(unit)
Server only
Destroys a unit.
If the unit does not exist at the moment, it is removed from the save file. This will stop it from loading back into the game.
Parameters:
| Type | Name | Description |
|---|---|---|
| Unit | unit | The unit. |
sm.unit.getAllUnits(world?)
Server only
Returns a table with all the units in the world.
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world? | The world to get units from. Defaults to the world of the script (Optional) |
Returns:
| Type | Description |
|---|---|
| table | The table of all units. {Unit, ..} |
sm.unit.getUnitsInRange(world, position, range, heightModifier?)
Server only
Returns a table with units within a given range.
Parameters:
| Type | Name | Description |
|---|---|---|
| World | world | The world to check in. |
| Vec3 | position | The position to check from. |
| number | range | The range to check. |
| number | heightModifier? | A value to modify the height of the range check. Defaults to 1. Higher values makes enemy elevation difference deemed as greater distance. |