In my procedural game worlds, I have a habitus of instantiating new objects like this:
GameObject character = (GameObject.Instantiate(characterPfb, location.position, location.rotation, transform)); NetworkServer.Spawn(character); DragAndDrop dnd = character.GetComponent<DragAndDrop>(); dnd.startPos = location; dnd.mainCam = Camera.main; dnd.gameState = gameState;
So I create the gameobject, get its script and fill it with all variables it needs to function.
Now, this doesn’t seem to work with mirror since the fields stay empty in the new object.
I have tried to pass all the variables to the Player script and let it set the variables via command.
Still, the fields remain empty.
I hate networking for how everything that would otherwise just work perfectly has simply no effect at all. As if I’d write all the code for nothing.
I would be very happy if someone could redeem me, and show me how to set up an instantiated gameobject correctly with mirror, so it has all its variables set.