Hi,
I’m kind of a beginner and I am working on a networked (LAN) 1vs1 2D table tennis game, where two can choose certain (animated) characters(as prefabs). The prefabs are made with the sprites facing to the right and the sprites have animations attached that change their positions(they move backwards out of the screen).
I am using the standard Network manager to setup the game, so when player one hosts a game he will spawn in the left edge of the screen, and if player 2 joins he will spawn right. I chose to use an empty gameobject centered in the middle that serves as a mirror. Since the character sprites are facing to the right, all characters have such a mirror as parent object. If player two is spawned I then set the x localscale of the mirror to -1. I have here an example of how the players are loaded in the offline version of the game:
public void LoadPlayers (int Player,string Character) {
if (Player == 1) {
P1 = (GameObject) GameObject.Instantiate (Resources.Load(“Characters/”+Character));
P1.transform.Find(Character).tag = “Player”;
}
if (Player == 2) {
P2 = (GameObject) GameObject.Instantiate (Resources.Load(“Characters/”+Character));
P2.transform.localScale=new Vector3 (-1, 1, 1);
P2.GetComponentInChildren ().direction = -1;
P2.transform.Find (Character).tag = “Player2”;
}
}
The problem is that I cannot seem to figure out how this would work in the networked version. The problem is I cannot add a Network Identity component to both the mirror and the character. If I leave the mirror without a NetworkIdentity component, the mirroring wont work (I cant add them as spawnable prefabs in the Networkmanager UI). If I leave the character without the networkidentity, then I cannot use NetworkAnimator, Transform (I would have to attach these to the mirror, but this is useless), and the syncronization does not work anymore. Is there any better way to approach this to mirror player two in a LAN game? maybe via script?