Entities are the base object in the SceneGraph.
- Objects in experiences are constructed of one or more entities.
- Entities are hierarchical. You can query your parent using
GetParent
and add child entities usingAddEntities
. - Behavior is added to entities through
component
s. You can add new components usingAddComponents
. - The structure and content of entities is dynamic and be changed at any time through your experience
.
Deriving from entity
In the SceneGraph system a class that derives from entity
is also known as a prefab. Prefabs are useful when you
want to spawn/re-use a collection of entities and components many times within your game. Primarily prefabs are
authored through the editor, with their Verse classes generated as part of the build into the projects
Assets.digest.verse file.
While you can create base prefabs for common game object types like a vehicle or character, we highly recommended that you do not add code directly to the entity class, and instead keep logic in components. Keeping logic and data in components allows you to restructure your prefabs throughout production of your experience, without needing to massively refactor your class structure.
Verse using statement |
using { /Verse.org/SceneGraph } |
Members
This class has functions, but no data members.
Functions
Function Name | Description |
---|---|
GetParent |
Returns the parent entity of this entity.
|
RemoveFromParent |
Removes this entity from its parent. This is used to remove entities from the scene.
|
AddEntities |
Adds the provided entities as children of this entity.
|
GetEntities |
Returns the child entities belonging to this entity which are accessible from the calling context.
|
GetComponent |
Succeeds and returns the child component of type |
GetComponents |
Returns the child components belonging to this entity which are accessible from the calling context. |
AddComponents |
Adds the provided components to the entity.
|
SendDirect |
Send a scene event to only this entity. Returns true if the event was consumed. |
SendUp |
Send a scene event to this entity and its ancestors. Events do not propagate beyond the Simulation Entity. OnReceive will be invoked for each entity. Consuming the event will halt propagation to the next ancestor. Returns true if the event was consumed. |
SendDown |
Send a scene event to this entity and all of its descendants. OnReceive will be invoked for each entity. Consuming the event at any entity will halt propagation down that subtree. Entities are traversed in breadth-first order, i.e. each layer is evaluated before moving deeper. Returns true if the event was consumed. |