2019-05-22 20:56:04 +00:00
---
title: "Message"
date: 2019-05-22T13:10:43-07:00
weight: 7
---
Similar to Components, Messages are collections of data.
Messages are used to transmit data between Engines so they can manipulate the game state accordingly.
2019-12-01 21:43:31 +00:00
To define a message, declare a struct which implements the IMessage interface.
2019-05-22 20:56:04 +00:00
2019-12-01 21:43:31 +00:00
```cs
using Encompass;
2019-05-22 20:56:04 +00:00
2019-12-01 21:43:31 +00:00
public struct MotionMessage : IMessage {
2020-07-12 19:09:27 +00:00
public Vector2 Motion { get; }
2019-05-22 20:56:04 +00:00
}
```
2020-03-02 08:22:23 +00:00
Messages are temporary and Encompass destroys all its references to them at the end of the frame.
2019-05-22 20:56:04 +00:00
2020-03-02 08:22:23 +00:00
{{% notice tip %}}
2020-07-11 00:06:40 +00:00
Again, because structs are value types, and Encompass stores them in a particular way, we can create as many of them as we want without worrying about creating pressure on the garbage collector. Neato!
2019-05-22 20:56:04 +00:00
{{% /notice %}}