1st Stage Completion

Seamless Authentication: Updated LoginManager.cs so that Unity Services initialize before loading saved credentials, guaranteeing autofill and error-free signup/login flows.

Improved Spawn Mechanics: Refined GameplaySpawnManager.cs to deterministically assign spawn points based on team and actor order, ensuring consistent player placement every match.

Live Model Selection: Leveraged ChangeModels.cs and PlayerModelManager.cs to let players toggle character models at runtime RPC calls propagate changes to all clients in real time.

Persistent Team & Model Data: Extended GameManager.cs to store team IDs and clothing masks in Photon CustomProperties, so selections survive across scenes and reconnects.

Random Level Selection on Ready: In Ready.cs, once every player’s “Ready” flag is set, the master client picks one of three levels at random and uses PhotonNetwork.LoadLevel(...) to transport everyone simultaneously.

Cross-Scene State Preservation: Used DontDestroyOnLoad on instantiated player objects and relied on CustomProperties to carry clothing toggles and team assignments seamlessly into the gameplay scene.

For recent progress click on the link below
https://drive.google.com/drive/folders/1Nimt3-yUrj6zFsaNQU86RiGx78LjC-nU?usp=sharing

// Improved Start() in LoginManager.cs
public async void Start()
{
    await InitializeUnityServices();
    LoadSavedCredentials(); // ensures credentials load after services init
    loginButton.interactable = true;
    signOutButton.onClick.AddListener(SignOut);
    signOutButton.gameObject.SetActive(false);
}

// Deterministic spawn in GameplaySpawnManager.cs
private void SpawnLocalPlayer()
{
    int team = (int)PhotonNetwork.LocalPlayer.CustomProperties["team"];
    Transform[] spawns = (team == 1) ? team1SpawnPoints : team2SpawnPoints;
    var teamPlayers = PhotonNetwork.PlayerList
        .Where(p => (int)p.CustomProperties["team"] == team)
        .OrderBy(p => p.ActorNumber)
        .ToList();
    int idx = teamPlayers.FindIndex(p => p.ActorNumber == PhotonNetwork.LocalPlayer.ActorNumber);
    idx = Mathf.Clamp(idx, 0, spawns.Length - 1);
    PhotonNetwork.Instantiate(playerPrefab.name, spawns[idx].position, spawns[idx].rotation);
}

// Live model toggles in ChangeModels.cs
btn1.onClick.AddListener(() => localPlayer.ToggleModel(0));
btn2.onClick.AddListener(() => localPlayer.ToggleModel(1));
// ...
[PunRPC]
private void RPC_ToggleModel(int index)
{
    modelObjects[index].SetActive(!modelObjects[index].activeSelf);
}

// Random level pick in Ready.cs
private void TryStartGame()
{
    var scenes = new[] { 4, 5, 6 };
    int next = scenes[Random.Range(0, scenes.Length)];
    PhotonNetwork.LoadLevel(next);
}

Related games implementation features and practices

  • Fortnite and Warframe let players swap cosmetic elements live, updating all clients via RPCs for real-time consistency.
  • Overwatch uses deterministic spawn logic to balance teams, similar to ordering by ActorNumber in PUN.
  • Counter-Strike style ready-check and map-vote systems inspired the random level selection once every participant toggles “Ready.”

Analysis of implementation

  • Authentication Metrics: Track signup/login success rates and average auth latency.
  • Spawn Reliability: Log spawn‐point selection failures or out-of-range index errors.
  • Model Update Latency: Measure RTT for RPC-driven model toggles across clients.
  • Ready-Flow Robustness: Verify master-client starts only when all participants are flagged ready.

Results and Feedback on the implementation

  • Zero Auth Errors: Autofill and sign-in flows now run smoothly, eliminating manual credential re-entry.
  • Spawn Consistency: No out-of-bounds errors observed; players always appear at team-appropriate spawn points.
  • Real-Time Models: Testers report instant feedback when toggling clothing or models, with no noticeable lag.
  • Stable Ready Logic: Random scene loads execute without desync, delivering varied map experiences.
  • Next Steps: Add visual ping indicators for spawn fairness, introduce a short grace window before finalizing deletions, and log RPC failures for debugging.

References


Comments

Popular posts from this blog

Login Implementation

Basic Implementation