Leave a session
Learn how players can leave a session and what happens when they exit.
Read time 1 minuteLast updated a day ago
When players leave a session or get kicked out of the session, their player ID is removed from the players list. If the host leaves the session, another player in the session is randomly selected as the host. The host can also remove other players from the session. The same
RemovePlayerAsyncplayerIdusing Unity.Services.Multiplayer;using UnityEngine;// ...try{ // Assume 'session' is the active ISession instance the player has joined. // Leaving the session automatically removes the authenticated local player // from the backend service and safely shuts down associated network modules. await session.LeaveAsync();}catch (SessionException e){ // The Multiplayer Services SDK uses SessionException for API errors. Debug.Log(e);}