Previous Lecture Complete and continue  

  Defining the basic player data: an introduction to ECS entities and components, part 1

The player in our game is an ECS entity, with the PlayerData component attached to it:

As you can see in the previous fragment of code, ECS components are plain structs implementing the IComponentData interface. This interface lives in the Unity.Entities namespace. Note how we are putting all of our code inside the CCG namespace. This is a good practice to prevent name clashes when using third-party code.

The PlayerData struct stores two integers:

  • Hp: the player's current health.
  • Coins: the player's current number of coins.

As we will see during the course, the ECS is all about structs and value types rather than classes and reference types. This is one of the main reasons behind its "performance by default" motto.