Hi guys i have to send GameObject to clients, i tried by RPC calls but it doesn't work i was looking for solution in web, but people there say it is impossible to send gameobject or transform by RPC call, so how can i do that in other way???
Either you serialize it into something that is supported or you send the data needed in a supported format to create the GameObject. GameObject itself is not a valid RPC param.
I just have to tell scripts which game object is current target (only server knows that so i have to send this information to clients) is it possible??
If the GameObject you want to send has a networkview component attached to it, you could send the viewID of the networkview instead. You can then access the GameObject via NetworkView.Find(viewID).gameObject.
Ok, but how to do that by rpc call, i tried something like this : networkView.RPC("Enemy",RPCMode.All, closest.networkViewID); but it doesn't work, any ideas??
What doesn't work? The RPC or finding the object? If you want help, you will need to provide more detailed info.
Ok, so i try to send RPC and i am doing this like that but it doesn't work in that way, what is wrong???? Code (JavaScript): networkView.RPC("Enemy",RPCMode.Others, closest.networkViewID); var ID : NetworkViewID; @RPC function Enemy (target : NetworkViewID) { ID = target ; }
Ok, now i have @RPC, but i got this error : (line 84 is RPC call) Sending RPC failed because 'Enemy' parameter 0 was null UnityEngine.NetworkView:RPC(String, RPCMode, Object[]) AI_ZOMBIE1:FindClosestEnemy() (at Assets/Skrypty/AI_ZOMBIE1.js:84) AI_ZOMBIE1:Update() (at Assets/Skrypty/AI_ZOMBIE1.js:19)
The error is clear: Sending RPC failed because 'Enemy' parameter 0 was null The param your sending (closest.networkViewID) is null.
Ok, so i changed closest.networkViewID to closest.networkView.viewID, and also i had some stupid mistake in the rest of script, so now it is working perfectly , thank you guys for your help : )