![]() So, my question is, can I get Unity's NetworkView.RPC method to put it's serialised objects into this "args" parameter? If not, can anyone see anyway around this?īy the way I'm using Vexe's framework, so you might see unusual things like "base.Serializer" etc. Object deserialisedArgs = new object įor( int i = 0 i ( ( string )args ) First we have to deserialise the method arguments. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers. The RPC method: private void ComponentRPCNetwork( params object args ) Unity is the ultimate game development platform. The only problem now is, Unity won't put the objects it serialises into my params object parameter. I also put the unique component name and method name in the array. NetworkView.RPC( "ComponentRPCNetwork", mode, serialisedObjects ) Serialise arguments and call our RPC method through Unity. Despite of Master Server mode which requires connection to the Internet. So, I now I serialise them IF they're not a NetworkViewID, then send the entire object array to Unity, which it does interpret correctly: protected void ComponentRPC( string methodName, RPCMode mode, params object args ) WIFI Local Area Network (WLAN), in which Unity network view component and. So, serialising the whole array of objects isn't an option. That's fine, except as far as I can tell, Unity's NetworkView.RPC method is the only thing in the universe that knows how to serialise a NetworkViewID properly. Serialising the entire array results in Unity doing no serialisation in NetworkView.RPC. This method simply serialises the parameters into a string and sends them to unity's RPC method. So, now every RPC call should go through my RPC method. So, to fix this I've added a unique name to every component and have to do some relatively slow searching and reflection in order to have a safe RPC call. This means an arbitrary component will be the "this" of the RPC method that actually gets called. "RPC function names should be unique accross the scene, if two RPC functions in different scripts have the same name only one of them is called when RPC is invoked" This means if I have two components that share a base class that has an RPC method, they won't work due to this: Every component that a game object uses is placed on the object and is disabled/enabled based on it's state machine's current state. So in this setup the new owner sends a RPCMode.Server RPC with the new ID, and then the server does its own RPCMode.AllBuffered RPC to relay that to all the clients.Why do I need to do this? The game I'm working on fully conforms to a component style design. The solution to that was to have the server change the IDs on its own NetworkViews, and then send another RPC to all the clients telling them to change their IDs. Secondly, if you send the RPCs to change IDs from a client, the server can sometimes send an additional state change from the old ID and clients receive that after they've changed to the new one, and that also gives an error on the clients when they can't find the NetworkView. I worked around that by having an extra NetworkView on my objects which I just use for RPCs, and that NetworkView is forever owned by the server and never gets its ID changed. They still get sent, but a newly connecting client can't find the NetworkView and gives an error. It brought up a couple of issues that I hadn't anticipated, though:įirstly, changing the view ID messes up any buffered RPCs that were sent via the old ID. Either enter your email address to register for the cloud, skip this step to enter the AppId of an existing account or switch to 'self hosted' Photon to enter your server's address. I've just tried this out this week and I can confirm that it does indeed work as expected. PhotonNetwork Plugin For Unit圓D When you import PUN, the 'Wizard' window will popup. Hopefully this helps, I haven't actually tried doing this myself but if it is possible to do want you want to do, this is probably the most likely way of doing it. ![]() This way you don't break the viewid relationship across all computers running the game. If you want to transfer ownership of an object it should be possible to do by allocating a new view id for the object on whoever you want to own the object and then assign the new id to the existing networkview, and the owner should now be changed.īut you would want to allocate the id first then send an rpc to all the other versions of the object on remote computers to change the id and then set the id. Then the client will be the networkView.owner, if you were to do that on the server, the server would be the owner. From my understanding of Unity networking so far where ever you allocate the networkview.viedID is who the owner is.įor example is you instantiate an object that has a networkview on a client and then on that client says, Kinda, but not in a very nice and direct way.
0 Comments
Leave a Reply. |