Communication between two entities in a system

Hello,
I’m having a problem with ECS systems.
I’m working on a PVP game between 2 teams, each team has a spawn zone.
Spawn zones are entities just like players.
In the following code, I tag players who have run out of lives with a WaitForRespawnTag.
In a second system, I want the tagged players to teleport to their respective spawn zones.
However, I can’t find a “clean” way to make the player and spawner entities communicate with each other…
I’ve found this solution, but I don’t quite understand it, and the sintax is obsolete today…

Otherwise, here is my code:

public partial struct SpawnerSystem : ISystem
{
    public void OnUpdate(ref SystemState state)
    {
        EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

        foreach (var (health, entity) in SystemAPI.Query<RefRO<Health>>()
            .WithAll<Simulate>()
            .WithAll<PlayerTempsTag>()
            .WithEntityAccess())
        {
            if (entityManager.HasComponent<WaitingForRespawnTag>(entity)) continue;

            ref readonly Health hp = ref health.ValueRO;

            if (hp.Value <= 0)
            {
                entityManager.AddComponent<WaitingForRespawnTag>(entity);
            }
        }
    }
}

public partial struct RespawnSystem : ISystem
{
    public void OnUpdate()
    {
        foreach (var waiterLocalTransform in SystemAPI.Query<RefRW<LocalTransform>>()
            .WithAll<WaitingForRespawnTag>()
            .WithAll<NatifTeamTag>())
        {
            ref LocalTransform waiterTransform = ref waiterLocalTransform.ValueRW;

            foreach (var (physicsCollider, spawnerComponent, spawnerLocalTransform) in SystemAPI.Query<RefRO<PhysicsCollider>, RefRO<SpawnerComponent>, RefRO<LocalTransform>>()
                .WithAll<NatifTeamTag>())
            {
                ref readonly PhysicsCollider collider = ref physicsCollider.ValueRO;
                ref readonly SpawnerComponent spawnerData = ref spawnerComponent.ValueRO;
                ref readonly LocalTransform spawnerTransform = ref spawnerLocalTransform.ValueRO;

                //???
            }
        }
    }
}

One solution would be for the players to have a reference to their respective team and the team to reference their spawn zones.

 public void OnUpdate(ref SystemState state)
    {
        EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager;

        foreach (var (player, playerTransformRef) in SystemAPI.Query<RefRO<Player>, RefRW<LocalTransform>>().WithAll<WaitingForRespawnTag>())
        {
              //get the respawnZones of the players team
              var respawnZones = entityManager.GetBuffer<RespawnZones>(player.ValueRO.teamEntity);

              //pick a respawn zone to respawn at (i just picked the firrst one)
              var respawnZone = respawnZones[0].entity;
        
              //Do respawning work
              ref var playerTransform = ref playerTransformRef.ValueRW;
              playerTransform.position = m.GetComponentData<LocalTransform>(respawnZone).position;
        }
    }

This is pretty bare bones and pretty much pseudo code.

Hi, sorry for the late reply, I have only recently been able to get back to the project.
Thanks for the solution, I tried it and it works fine.
However, I couldn’t keep it as it conflicted with the server (without entering the details).
So I used a SystemAPI.GetSingletonEntity to get the spawners.
This is the best solution I’ve found so far, but I’m still surprised that no methods seem to have been thought of specifically to make two entities communicate, it’s not as if this is a rare need…