You could always put all server's Network.Instantiates in a different group for each player, and use RemoveRPCs() and specify the group. You'd just need to keep a lookup table somewhere to remember what group is associated with what player.How do the buffered RPC messages for the Network.Instantiate get destroyed if they're owned by the server? Is unity smart enough to know that if you're destroying the object associated with a Network.Instantiate then it should destroy the buffered RPC associated with its creation too?
Is there a way I can check if a NetworkViewID exists?
When two bullets are fired at a non-player-object (in my case a rigidbody asteroid) the first bullet may destroy the object where the server executes Network.RemoveRPCs(networkViewID) and Network.Destroy(networkViewID).
The second bullet that hits a split second later generates two error messages:
The first error I can't seem to do much about - I believe Unity may have cached network traffic to the object and it's natural for this error to occur? Can anyone confirm this?
The second error I could eliminate by checking if the NetworkViewID exists - but I haven't found a way to do this. I triedAny suggestions on this?Code:
I solved the second error, I had to use if (target_NetworkView != null) before I tried to get the transform of networkViewID.
The first error remains though and I think this is standard Unity behavior if two bullets register a hit in the same Update() and the first bullet has enough power to destroy the object.
Last edited by imphy; 09-23-2011 at 12:38 AM. Reason: Solution for error 2 and more info on problem 1
implies that your solution should work when it says:
The NetworkView attached to this GameObject (Read Only). (null if there is none attached)
I think that the problem is, looking at this page, by saying:
- if (networkViewID != null)
... you are checking if the network view exists on this object.
Looking at the sample code:
... you need:
Now you may have tried this in your actual code, but from reading what you've posted this seems to be a possible issue.
The Google Custom Search Engine for Unity3D: http://tinyurl.com/Unity3dSearchEngine
Learning Resources for Unity3D:
On the Unity3D forum | Unity3D Resources | Getting Started with Coding for Unity
I'm still not able to get networking through a master server to work on mobile devices using 3G. Mobile devices work just fine on wifi, but once I switch to 3G they continue to show up in the server list but cannot be connected to.
Any insight would be appreciated.
I bought this tutorial a few months ago in hope to getting around to it and I am getting this error-
Connect.js(40,33): BCW0012: WARNING: 'UnityEngine.Network.InitializeServer(int, int)' is obsolete. Use the IntializeServer(connections, listenPort, useNat) function instead
Not sure what needs to be done to fix this????
All_American: You can probably download an updated version of the tutorial files if you have purchased it before. Go to the Unity Asset Store and click on the "downloads" button at the top (next to the house icon)
I bought your package and I have to say congratulations. Your job was great.
However, I am having a problem and I would like to know if you can help me.
My game is going to run only in a LAN with no internet connection.
In my case, the server computer has to run the server application and the unity Master Server (according to what I understood about unity network)
The problem is: if I have the Master Server running, when I try to run the server game unity returns a error message:
Did anybody have this problem already? How can I fix it?Failed to initialize network interface. Is the listen port already in use?
UnityEngine.Network:InitializeServer(Int32, Int32, Boolean)
Thanks a lot
Hi Leepo. Thanks for your attention
In my case, I have only the Master Server app (downloaded from unity website) running and after that I run Unity Editor.
My pipeline is as follow:
1) Start Master Server
2) Start Unity Editor -> Example2_menu$MasterServer.exe -p 20000
24-11-2011 10:53:14 LOG Unity master server version 2.0.1f1
24-11-2011 10:53:14 LOG Master server port set to 20000
24-11-2011 10:53:14 LOG 1000 connection count limit
24-11-2011 10:53:14 LOG To quit press Ctrl-C
3) Edit MultiplayerFunction script at method SetupMasterServer
4) Play appMasterServer.port = 20000;
MasterServer.ipAddress = "127.0.0.1";
5) Error message popup
Again, any help is welcome
For all multiplayer devs: the GEE game development contest is also open for Unity networking projects(!), see: http://forum.unity3d.com/threads/112...-USD-in-prizes
Does this also cover lan games?
Vector Quaternion Genius - Unity Noob
-Insert quote here
-Insert quote here
"Jump" serialization in Tutorial 2A2 not working:
Hi, just bought the tutorial and I'd like to provide a bit of feedback to help improve it, if that's all right
In tutorial 2A2, the docs post the question "what if we want to move the cube in the Y-direction?", but the code for this in Tutorial_2A2.js is commented out, and you never actually mention the solution. Unfortunately, uncommenting this in both places in the OnSerializeNetworkView results in the following error:
- Assets/M2HNetworking/Tutorial 2/Tutorial_2A2.js(41,21): BCE0067: There is already a local variable with the name 'jumpBoolean'.
From a tutorial standpoint, this is kind of confusing since you are introducing the new concept of serialization. I would assume one would define the jump variable outside the function and then check it's value and serialize it if it's true in the serialize sections, but since in the docs you also say, "The OnSerializeNetworkView fuction always looks as strange as this.", it seems to imply that maybe this is done differently here?
What's the correct way to make this work?
Hi, i just bought and ran this UUNP, read through the pdf and had a look at the sample scenes. Without even building and testing it so far i can already say that it already shed light on a lot of my questions. GREAT!
I am actually interested in more information concerning network games using physics and unfortunately this is not covered at all.
So maybe somebody can give me some hints, or the author is willing to create another demo scene .
As an example, though not very realistic but somewhat easy to set up imagine a multiplayer pinball game, where player one controls the left flipper (bumper, wing, excuse my english, i mean the thing that a pinball player usually controls with a left and right button) and player two the other one.
Then of course there is the ball rigid body, affected by gravity. And there are some automatic bumpers, which are not controlled by a player (you know, those round things which push the ball themselves when hit).
From what i learned so far one can do it mainly like this:
1. The procedures of starting and joining the game are just like all the other demo scenes.
2. The flippers of the players can also be controlled as described in the other demo scenes.
3. The ball is a rigid body with network view, its transform state is observed and broadcasted by the server to the clients.
and now the tricky parts:
All in common: Where are the collisions being processed? Is this necessary on both machines?
- The ball hits a static bumper. such a bumper is just a collider. It either alters the movement of the ball by its physics material or by applying a force. Now, such a game object is usually in a scene, which the author calls "hard coded". He states this GameObject is thus owned by the server. So what does this mean now? Is the collision detected only on the server now? That would be desired. Or on both? That should not be necessary, as in the end, the balls transforms are observed. Which also means, that the colliders are not necessary on the client at all. So should the clients Gameobject remove its collider component on start?
On the other hand, the collision could also fire more things, like a visual feedback or some sound. For this the collider would be still useful. Or the server has to send some bumberdidhit RPC, to fire that.
Same thing would be even more tricky if those bumpers would move in some way...
Also, applying forces to the ball should only happen on the server. Not on server + clients.
And all this explained in a best practice way (avoid unnecessary physics calculations, or do those on the client as well and if for what reason?, keep network traffic low).
The pinball idea isn´t important, basically it could be anything that has:
- multiple players effect a rigidbody directly
- the rigid body gets affected be some forces on some event NOT controlled by the players.
And now my dumb question of the day:
Lets say you develop any game that could also work in network coop mode (lets say a topdown shooter). Would it be a good idea to create this as a network game from the beginning? I mean, the stand alone version of this could just be a start of the server without other players logging in.
I am asking because i cannot see to much of a drawback for this except the work to set everything up for network and maybe a slight performance hit. What do you think? ( -- ducks --- )
Last edited by marjan; 12-18-2011 at 03:32 PM.
Upon building each of the examples from a fresh project and testing by connecting on two seperate machines:
I'm able to connect okay, but the server description and message of the day never show up on the client. Not a major issue, but the big problem is that if I set a password on the server, there is no way to enter this password on the client, thereby making it impossible to join the game. Watching closely, I'm guessing that the password field is being drawn on the client and then immediately being overdrawn by the server name button, but it goes by too fast to be sure.
The password problem is the same as in Example two: The server can enter a password, but there's no field in the client GUI to enter it. In both examples there is the text "PW" to the left of the button to join. I don't know if this is just an indictor telling me that there needs to be a password or if it's a label to a password field that is no longer in view because the join button has been drawn over the top of it.
This one is actually a bit worse. Again, the server description and message of the day never show up, either in the lobby or the game, though I do realize the functionality may just have not been written in. In this case, however, the name of the server is also not displayed in the client multiplayer menu. Instead, all I see is "gevarres game" no matter what is typed in on the server (gevarre being the player name I'd typed in from a previous example).
This example also has the same problem of there being no field in which the client can enter a password.
A further problem with this example is that when there actually is a game running, once a player sends a chat (by hitting enter, entering their text, and hitting enter again to send it), they will be unable to move again until after pressing one of the mouse buttons. Not really a good thing when you've just taunted the sniper on the other side of the room and you are stuck out in the middle!
Obviously this one doesn't have the lobby problems because there is no lobby, but it does have the same chat problem as Example 4: once a player sends a chat, they will not be able to move until they click in the main window with one of the mouse buttons. It doesn't matter which one.
Has anyone else seen these problems, or is it just me? I'm using the current version of Unity (3.4.2f2) and the current version of the projects downloaded two days ago.
Hello Leepo and Unity3D Community…
I’m thankful for the Ultimate Networking Project as 1) it works :] and 2) it seems basic enough for a newbie like me to understand. I’m a programming instructor for 6th-12th graders, and I’m hoping that Unity3D would be a good gaming engine to teach development of multi-player networked games. As I'm studying Example 4 FPS, I need help in two basic areas:
1) When trying to tweak the initial values in Machinegun.js (such as my script values of “var damage=10.0; var bulletsPerClip=50; var clips=20”), such values get lost and are overridden in runtime when inspecting “PlayerPrefab(Clone).CrateCamera.Weapon”. First of all, I can’t find where “PlayerPrefab(Clone).CrateCamera” adopts “Weapon” as a child. Also, where do the new overriding values come from (such as “damage=20.0; bulletsPerClip=30; clips=5”)?
2) Also, does anyone have any recommendation regarding a good software/process (ideally low-cost or free to develop other level maps? It would be fun to have my students start by developing their own maps for this game.
Thanks again for any help. Anyways, I hope that this thread is still being supported. jay
Inspector values have precedence over the ones in the script. So you need to edit the ones you want in the inspector also or make the values private in the script.1) When trying to tweak the initial values in Machinegun.js (such as my script values of “var damage=10.0; var bulletsPerClip=50; var clips=20”), such values get lost and are overridden in runtime when inspecting “PlayerPrefab(Clone).CrateCamera.Weapon”. First of all, I can’t find where “PlayerPrefab(Clone).CrateCamera” adopts “Weapon” as a child. Also, where do the new overriding values come from (such as “damage=20.0; bulletsPerClip=30; clips=5”)?