Unit Class
Description:
A class for creating instances of Unit.
GroundSensorTag
Type: Readonly Field.
Description:
The tag for the "GroundSensor" attached to each "Unit".
Signature:
const GroundSensorTag: integer
DetectSensorTag
Type: Readonly Field.
Description:
The tag for the "DetectSensor" attached to each "Unit".
Signature:
const DetectSensorTag: integer
AttackSensorTag
Type: Readonly Field.
Description:
The tag for the "AttackSensor" attached to each "Unit".
Signature:
const AttackSensorTag: integer
__call
Type: Metamethod.
Description:
A metamethod that creates a new "Unit" object.
Signature:
metamethod __call: function(
self: UnitClass,
unitDef: Dictionary,
physicsWorld: PhysicsWorld,
entity: Entity,
pos: Vec2,
rot?: number --[[0.0]]
): Unit
Parameters:
Parameter | Type | Description |
---|---|---|
unitDef | Dictionary | A "Dictionary" object that defines the properties and behavior of the "Unit". |
physicsWorld | PhysicsWorld | A "PhysicsWorld" object that represents the physics simulation world. |
entity | Entity | An "Entity" object that represents the "Unit" in ECS system. |
pos | Vec2 | A "Vec2" object that specifies the initial position of the "Unit". |
rot | number | [optional] An optional number that specifies the initial rotation of the "Unit" (default is 0.0). |
Returns:
Return Type | Description |
---|---|
Unit | The newly created "Unit" object. |
__call
Type: Metamethod.
Description:
A metamethod that creates a new "Unit" object.
Signature:
metamethod __call: function(
self: UnitClass,
unitDefName: string,
physicsWorldName: string,
entity: Entity,
pos: Vec2,
rot?: number --[[0.0]]
): Unit
Parameters:
Parameter | Type | Description |
---|---|---|
unitDefName | string | A string that specifies the name of the "Unit" definition to retrieve from Data.store table. |
physicsWorldName | string | A string that specifies the name of the "PhysicsWorld" object to retrieve from Data.store table. |
entity | Entity | An "Entity" object that represents the "Unit" in ECS system. |
pos | Vec2 | A "Vec2" object that specifies the initial position of the "Unit". |
rot | number | [optional] An optional number that specifies the initial rotation of the "Unit" (default is 0.0). |
Returns:
Return Type | Description |
---|---|
Unit | The newly created "Unit" object. |