|
|
|
This class is used for creating any type of game object, assigning it a class, datablock, and even a function when it is spawned. More...

Public Member Functions | |
| bool | spawnObject (string additionalProps) |
| Dynamically create a new game object with a specified class, datablock, and optional properties. | |
Callbacks | |
| void | onAdd (int objectId) |
| Called when the SpawnSphere is being created. | |
Public Attributes | |
Spawn | |
| bool | autoSpawn |
| Flag to spawn object as soon as SpawnSphere is created, true to enable or false to disabled. | |
| string | spawnClass |
| Class assigned to object when created, such as Player, or AIPlayer. | |
| string | spawnDatablock |
| Predefined datablock assigned to the object when created. | |
| string | spawnProperties |
| String containing ; delimited properties that are set at the time of spawning. | |
| string | spawnScript |
| Command to execute when spawning an object. New object id is stored in $SpawnObject. Max 255 characters. | |
Weight | |
| float | indoorWeight |
| Deprecated. | |
| float | outdoorWeight |
| Deprecated. | |
| float | sphereWeight |
| Deprecated. | |
Dimensions | |
| float | radius |
| Determines the size of the sphere in which the object will spawn. | |
Static Public Attributes | |
| static bool | isRenderable |
| Disables rendering of all instances of this type. | |
| static bool | isSelectable |
| Disables selection of all instances of this type. | |
This class is used for creating any type of game object, assigning it a class, datablock, and even a function when it is spawned.
Torque 3D uses a simple spawn system, which can be easily modified to spawn any kind of object (of any class). Each new level already contains at least one SpawnSphere, which is represented by a green octahedron in stock Torque 3D. The spawnClass will determine the object type, such as Player, AIPlayer, etc. The spawnDataBlock will provide this specific instance of the creation with a pre-defined datablock. The really powerful feature of this clas is utilize by the spawnScript field. Through this, you can define a simple script (multiple lines) that will be executed once the object has been spawned.
new SpawnSphere(DefaultSpawnSphere) { spawnClass = "Player"; spawnDatablock = "DefaultPlayerData"; spawnScript = "echo(\"Object Spawned\");"; // Note the escape sequence \ in front of quotes spawnProperties = "name = \"Bob\";lifeTotal = 3;"; // Note the escape sequence \ in front of quotes autoSpawn = "0"; radius = "1"; sphereWeight = "1"; indoorWeight = "100"; outdoorWeight = "100"; dataBlock = "SpawnSphereMarker"; position = "-0.77266 -19.882 17.8153"; rotation = "1 0 0 0"; scale = "1 1 1"; canSave = "1"; canSaveDynamicFields = "1"; }; // In the above example, the following two lines of code will execute after spawning echo("Object Spawned"); echo("Hello World");
| void SpawnSphere::onAdd | ( | int | objectId | ) |
Called when the SpawnSphere is being created.
| objectId | The unique SimObjectId generated when SpawnSphere is created |
| bool SpawnSphere::spawnObject | ( | string | additionalProps | ) |
Dynamically create a new game object with a specified class, datablock, and optional properties.
This is called off the actual SpawnSphere, not to be confused with the Sim::spawnObject(...) global function
| additionalProps | Optional set of parameters applied to the spawn object during creation. |
// Use the SpawnSphere::spawnObject function to create a game object // No additional properties assigned %player = DefaultSpawnSphere.spawnObject();
Flag to spawn object as soon as SpawnSphere is created, true to enable or false to disabled.
Deprecated.
bool SpawnSphere::isRenderable [static] |
Disables rendering of all instances of this type.
Reimplemented from MissionMarker.
bool SpawnSphere::isSelectable [static] |
Disables selection of all instances of this type.
Reimplemented from MissionMarker.
Deprecated.
| float SpawnSphere::radius |
Determines the size of the sphere in which the object will spawn.
| string SpawnSphere::spawnClass |
| string SpawnSphere::spawnDatablock |
Predefined datablock assigned to the object when created.
| string SpawnSphere::spawnProperties |
String containing ; delimited properties that are set at the time of spawning.
| string SpawnSphere::spawnScript |
Command to execute when spawning an object. New object id is stored in $SpawnObject. Max 255 characters.
Deprecated.