Get SpatialOS

Sites

Menu

ECS: Temporary components

A temporary component is a type of component which only exists for a single frame. This pattern is useful when you want to represent transient events as an ECS component, for example, the OnConnected component which denotes that your worker has connected to the SpatialOS Runtime as described in the ECS: Worker entity documentation.

We provide you with the Improbable.Gdk.Core.RemoveAtEndOfTick attribute, which can be applied to any ECS component to make it a temporary component.

If a temporary component is added to an entity, the GDK removes the component using the CleanTemporaryComponentsSystem at the end of the update loop. This means that when you use temporary components, you must consider the ordering of your systems carefully. Any system which runs logic predicated on the temporary component should be run after the temporary component is added and before it is removed.

The following code snippet shows an example of how to annotate your ECS component with the RemoveAtEndOfTick attribute.

[RemoveAtEndOfTick]
public struct SomeTemporaryComponent : IComponentData
{
}

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums