Why Are You Using ClientConnections?
A common question I get is why I am setting the ClientConnection as the player object and not just making the spawned character as the Mirror "player", it's a design pattern?
One thing you will learn over your years of development is just because someone does something one way doesn't mean it fits everyones method. Mirror has a lot of issues when it comes to destroying character objects and preserving the scene. This removes those issues (like character assignment, client owned object reassignment, and more).
How Does This Object Help?
The ClientConnection object is a nice helper method that will allow you to still be a part of the scene without having to actually be "a part of the scene". What do I mean by that? I will list a few methods here that take advantage of this concept.
- Follow Cameras (You will have to maintain your character in the scene in order to do this.)
- Global character status/stats (Not possible if your character isn't in the scene, or you have to send a lot of custom
NetworkMessagesto accomplish) - Null object support
- Single scene querying (otherwise you will have to query every single loaded scene to find your exact player object, very inefficent! - not a problem if a single scene game, it is otherwise.)
But I Don't Wanna!
Fine, I'm not going to force you here. If you want to deal with the above issues and shoot yourself in the foot be my guest. Don't come back crying to me though when you have issues with invector and multiple additive scenes.
If you want to have the character be the Mirror player with a little work as possible just add the ClientConnection component to the character object and deal with the consquences yourself. I'm not going to help you on this one, good luck.