- Home /
NetworkReader/Writer with GameObject
Hello. I'm making a game, and I'm attempting to optimize the networking code as much as possible, and so I've made bitstreaming methods that allow me to write whatever types I desire with whatever precision/bitcount I want.
However, I also want to be able to bitstream GameObjects and other things. I know I can make a dictionary and keep track of the objects by IDs myself and reference them, but I feel that is ugly.
What is the underlying code behind NetworkReader and NetworkWriter's reading/writing of a GameObject or how could I replicate this in an efficient manner? I'd like to be able to stream this wherever I want, so I could transmit GameObject references in a way that isn't byte-aligned (8-bit aligned) to save the user a little bit of network traffic.
Also, one more question, if a GameObject is transmitted currently in unity, and the client hasn't spawned it yet, obviously the GameObject reference would be return null. But if the user keeps that reference, will it link when the object has spawned, or is the linking only done when the reference is first received? I figure the latter, but it's worth asking since I know unity does do a lot of nice fixing up for the user.