S2ENGINE HD  1.4.6
Official manual about S2Engine HD editor and programming
Objects

Objects are basic elements of game simulation in S2Engine. There are many different objects included into the various plugin dlls included into S2Engine package.

Object activation

Every object into the scene is stored into a list called 'STOCK Objects List'.
In this list are stored various kind of object that can be classified into four main categories:

  • Statics They are object visible into the scene but they do not move. They can be lights, sound sources, simple static meshes. Unlike Active Objects they aren't updated during the main game loop.
  • AI helpers These object are not pushed inside the scenegraph, they do not move, they are only logic. They are useful as helper for AI system, and can be points, areas, volumes.
  • Active All other stock objects are 'sleeping' objects, they do not move, they aren't pushed into the scene, they do not help the AI system. they do not make anything. To make something a stock object must be ACTIVATED. When an object is activated it is duplicated, initialized (its model is loaded, the initialization script block is executed, animation script is loaded, etc.) and finnally pushed into scenegraph. Active objects are objects that are activated just when a simulation start (after loading a game level, or restarting it). They are updated during the main game loop at every frame unless they are sleeping. Active Objects Transformation matrix is also updated at every frame unless you reset the moved flag at the end of Update() or PostUpdate() function. To make an object Active you have to set true its activable param.
  • NON-Active Non-active object are similar to active objects except for the fact that they aren't activated just when the simulation start. They have to be explicitly activated by script or by object internal C++ code. This fact is useful when you must make objects like projectiles, decals, explosions, etc. Projectiles are actived only when gun shoots, decals are actived only when projectile impacts the wall, etc. So in the definition of the scene (see S2SceneStudio) these object are defined only once, then are duplicated and actived when it is needed. To make an object NON-Active you have to set false its activable param.

To activate an object you can use the ActiveObject function.
It is also possible to active an object and attach it to the node of the hierarchy of another object with a single function: AttachObject.

Object spawing

From version 1.4.6 there is a new method for instancing objects: Spawing.
Instead of activating NON-Active objects already existing inside the global stock list of a scene, you can instantiate objects by loading a prefab. This operation is called "spawing".
You can spawn an object by calling function SpawnObject.

How Spawing works?

SpawnObject function takes in input a prefab resource (see PrefabsInspector).
A prefab resource is a file containing the definition of one or more objects:

  • If prefab contains more than one object, the first object is created and activated, all the others are stored inside stock list if and only if they are NON-activables, no operation is made if they are helpers, statics or activables.
  • If prefab contains a single object it is instanced if it is an helper or a static, otherwise it is activated even if it is NON-activable.

The following is a graphic diagram about how spawing works:

spawning.jpg

About Spawned Object Names

Spawing vs Activation

Object Classes

SceneObject is the base class for all object componing a scene.
For the complete list of object classes provided with basic Engine package see BasePack .

See also
Objects and ClassInspector to know how to create, place, move and edit object inside the scene.