sm.unit
Unit creation and management
Server-only
createUnit
sm.unit.createUnit( uuid, feetPos, yaw, data, pitch, visible )
Creates a new unit of type from an Uuid
Parameters:
| Name | Type | Description |
|---|---|---|
uuid |
Uuid | The character type uuid. |
feetPos |
Vec3 | The feet position in world where unit should spawn. |
yaw (optional) |
number | The initial yaw. Defaults to 0 (Optional) |
data (optional) |
any | The param data. (Optional) |
pitch (optional) |
number | The initial pitch. Defaults to 0 (Optional) |
visible (optional) |
boolean | Whether the unit is visible on spawn. Defaults to true. (Optional) |
Returns:
| Type | Description |
|---|---|
| Unit | The created unit. |
forceDestroy
sm.unit.forceDestroy( unit )
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:
| Name | Type | Description |
|---|---|---|
unit |
Unit | The unit. |
getAllUnits
sm.unit.getAllUnits( world )
Returns a table with all the units in the world.
Parameters:
| Name | Type | Description |
|---|---|---|
world (optional) |
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, ..} |
getUnitsInRange
sm.unit.getUnitsInRange( world, position, range, heightModifier )
Returns a table with units within a given range.
Parameters:
| Name | Type | Description |
|---|---|---|
world |
World | The world to check in. |
position |
Vec3 | The position to check from. |
range |
number | The range to check. |
heightModifier (optional) |
number | A value to modify the height of the range check. Defaults to 1. Higher values makes enemy elevation difference deemed as greater distance. |