• Called once per player when they arrive.

    By default this waits for the avatar profile component, so avatar is set. Pass { requireProfile: false } to be told as soon as the player's identity exists — see PlayerEventOptions for what each threshold guarantees about the name.

    By default this also fires once for each player who already satisfies the threshold — see replayPresent in PlayerEventOptions.

    Do not cache player.entity past the callback: the entity backing an address can be replaced without an event (see GetPlayerDataRes.entity).

    async handlers are supported; a rejection is logged and isolated, never left unhandled, and never stops the other handlers.

    Returns

    an unsubscribe function

    Example

    // rendering: wait for the profile, and render displayName (name may be unresolved)
    onEnterScene((player) => addNameplate(player.userId, player.displayName))

    // server presence: react as soon as the player exists
    onEnterScene(async (player) => {
    const profile = await store.load(player.userId)
    room.send('profile', profile, { to: [player.userId] })
    }, { requireProfile: false })

    Parameters

    Returns (() => void)

      • (): void
      • Called once per player when they arrive.

        By default this waits for the avatar profile component, so avatar is set. Pass { requireProfile: false } to be told as soon as the player's identity exists — see PlayerEventOptions for what each threshold guarantees about the name.

        By default this also fires once for each player who already satisfies the threshold — see replayPresent in PlayerEventOptions.

        Do not cache player.entity past the callback: the entity backing an address can be replaced without an event (see GetPlayerDataRes.entity).

        async handlers are supported; a rejection is logged and isolated, never left unhandled, and never stops the other handlers.

        Returns

        an unsubscribe function

        Example

        // rendering: wait for the profile, and render displayName (name may be unresolved)
        onEnterScene((player) => addNameplate(player.userId, player.displayName))

        // server presence: react as soon as the player exists
        onEnterScene(async (player) => {
        const profile = await store.load(player.userId)
        room.send('profile', profile, { to: [player.userId] })
        }, { requireProfile: false })

        Returns void