|
Hi everyone. I've got a problem. I have a multiplayer game, and when it starts i use a function to instantiate the player. The thing is that the client does exactly what the server does, i mean, if my player in the server turns around and ends up looking at a tree, the client does the same. This is the code i use to instantiate the players. Please help me i have no clue. function OnNetworkLoadedLevel () { } When the game is running the players are instantiated in client and server, but just the local player has attached a networkview component and the "Move" Script, so, i dont think the script is controlling the other player. Thanks, regards.
(comments are locked)
|
|
That's because you use What you should do is write your custom instantiate RPC and within it change the name, attach the components etc. Also note that you always need to attach a NetworkView component, and that this component has to have the same networkViewID across all connected machines, server and clients in order for it to synchronize correctly. You can assure that by adding a call to It is important to realize that the network owner of an object is the last player to allocate it a viewID. This means that if a player calls Hi thanks for the answer. I'm a little lost here, because i had another game, and i load the players in the OnNetworkLoadedLevel () function. I think i know what it is, but just in case i'm mistaken, could you please tell me, the player prefab has a networkview, you said that the networkview ID in the server has to be the same that the networkview ID in the client? if not, it they wont synchronize correctly? Thanks, i will try what you tell me, in case i cant make it work, do you mind if i ask you some more questions? Thanks.
Mar 14 '12 at 06:29 PM
jaramillo
Not at all, although I can't guarantee an answer. :) You are correct, though. The player prefab has to have the same If the player prefab comes with a
Mar 15 '12 at 01:50 AM
asafsitner
Thanks. I found the problem, i have some RPC functions on my Main Camera and since it has a NetworkView component it seems like it was synchronized with all cameras in the clients. One more question, is there any way to do something like this? : var nView : NetworkView; nView = clone.GetComponent(NetworkView); nView.viewID = 10; I mean assign a viewID directly. Thanks
Mar 15 '12 at 06:21 AM
jaramillo
Yes, except that instead of assigning like this: you use Network.AllocateViewID() to reserve an ID. Then, you can pass this around by RPC to all the rest of the clients.
Mar 15 '12 at 06:31 AM
syclamoth
(comments are locked)
|
