• Called once per player when they go away — mirroring the threshold of the matching onEnterScene. With the default requireProfile, that means either the player left or their avatar profile went away; with { requireProfile: false }, only when their identity is gone.

    Do not rely on getPlayer(userId) here — what it returns depends on which threshold fired. On the identity threshold the entity is gone and it returns null; on the default threshold it can still return a live player, because only the avatar profile went away while the identity is still present. The last known state therefore arrives as the second argument, and is the only reading that is correct in both cases.

    Returns

    an unsubscribe function

    Parameters

    • cb: ((userId: string, lastKnown: Readonly<{
          displayName: string;
          isGuest: boolean;
          joinedAtMs: number;
          name: string;
          nameResolved: boolean;
          userId: string;
      }>) => void)
        • (userId: string, lastKnown: Readonly<{
              displayName: string;
              isGuest: boolean;
              joinedAtMs: number;
              name: string;
              nameResolved: boolean;
              userId: string;
          }>): void
        • Parameters

          • userId: string
          • lastKnown: Readonly<{
                displayName: string;
                isGuest: boolean;
                joinedAtMs: number;
                name: string;
                nameResolved: boolean;
                userId: string;
            }>

          Returns void

    • Optional options: PlayerEventOptions

    Returns (() => void)

      • (): void
      • Called once per player when they go away — mirroring the threshold of the matching onEnterScene. With the default requireProfile, that means either the player left or their avatar profile went away; with { requireProfile: false }, only when their identity is gone.

        Do not rely on getPlayer(userId) here — what it returns depends on which threshold fired. On the identity threshold the entity is gone and it returns null; on the default threshold it can still return a live player, because only the avatar profile went away while the identity is still present. The last known state therefore arrives as the second argument, and is the only reading that is correct in both cases.

        Returns

        an unsubscribe function

        Returns void