Search code examples
c#unity-game-engine3dmultiplayermirror

Player joins game Unity Mirror


I'm making a football game and I want to set the score of both teams to 0 once a new Player joins(it's a 1v1 game so that makes sense). Im using Unity 2022.3.1.16f1 and the latest version of Mirror.

I've tried using OnPlayerConnected() which did'nt work I also looked at the documentation and tried using OnClientConnect() which didn't exist.


Solution

  • I found out what's wrong... You can only use OnPlayerConnected() in a script thats of the type NetworkManager which mine wasn't. I found a way around it by just referencing said script in my actual NetworkManager and then setting the varible in OnPlayerConnect() in the NetworkManager... hope that helps anyone facing the same/a similar issue.