|
3 colors for 3 players |
Adding colors to
Droids proved to be a lot more difficult than I had imagined. Sending all of this data as a one-shot RPC call on player connect was just creating a maze in my head, and things weren't working quite as I had expected.
My ultimate solution was a combination of wasteful serialization and some RPC calls. The server is the only app that handles color management. It also now tells clients when to spawn their droids. When the droid is spawned, it immediately sends out an RPC telling that client to change its droid's color to whatever color it assigned for that player (keyed by player GUID).
|
Clearly, green is hacking here. |
That alone was not enough, however. New players joining wouldn't get old player data. Using the
OnPlayerConnected event to fire off colors to joining players didn't seem to cut it. In the end I just added a new
NetworkView, tied it to the
DroidColor, and added an
OnSerializeNetworkView to send the color segments over the wire. In the future I'd like to cut back on state sync, but at this point I'd rather move onto other features and this just might be over-optimization.
As normal, the
new version of the Droids game (web and stand-alone builds) are up in the
games section.
Happy to hear you found a way to make it work, in the end :).
ReplyDelete