Entity-Component Model

Overview

Entity is the base class for objects that are managed by the high-level engine. To improve flexibility, entity are component-based: they can contains as many components as required, containing data and/or logic. A @’Xenko.Engine.Entitycomponent’ is tied to its entity (that is, one component can’t be added to two entities at the same time).

How to create an entity and some components

  1. // Create entityvar myEntity = new Entity();// Create a model component (so that model is rendered)var modelComponent = new ModelComponent { Model = model };myEntity.Set(ModelComponent.Key, modelComponent);// Set entity positionmyEntity.Transformation.Translation = new Vector3(100.0f, 100.0f, 0.0f);// Add entity to scene; from now on its model will be renderedEntities.Add(myEntity);