What is the value/reason for components to be single objects?

I found a minor issue in that I have a component that is part of two different archetypes, and during a job I have to compare one archetype against another and Unity gave me an error because of this. So, I need to combine a couple in one archetype. This is fine, not a problem. However, before I get too far I thought I’d ask if someone has a paper or video detailing when/why to separate out components into single value

ie:

public struct RoadIdentityComponent : IComponentData
{
    public int value;
}

public struct LaneIdentityComponent : IComponentData
{
    public int value;
}

VS

public struct RoadLaneIdentityComponent : IComponentData
{
    public int roadIdentity;
    public int laneIdentity;
}

A couple of things. Let’s say you wanted a turnLaneIdentity instead of a laneIdentity, the former allows that. Not the greatest example here, but it comes up a lot in practice. The other factor is lets say you have a job that only processes roadIndentity values. By combining them, your memory efficiency drops from 100% to 50%. That might not actually matter if it saves you development effort by keeping them together.

1 Like

Thanks, I will keep this in mind.