Search Unity

  1. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  2. Unity 2017.2 beta is now available for download.
    Dismiss Notice
  3. Unity 2017.1 is now released.
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  6. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice

Unity Multiplayer UNet Sample Projects

Discussion in 'Multiplayer Networking' started by seanr, Jun 9, 2015.

  1. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    Attached to this post are some sample projects for the new networking system. These projects all use the High Level networking API.

    Warning, these contain programmer art and are not pretty at all.

    2dshooter - is a 2d shooter game, use arrow keys and space bar, start with the "start" scene.

    tanks - is a 2d tank example, use mouse and arrow keys, start with the "title" scene.

    Invaders - is a 2d arcade game, use arrow keys and space bar, start with the "StartMenu" scene.

    NetworkStarter - is simple 3d with boxes, it uses the multiplayer lobby and does scene changes, start with the "lobbyNewGUI" scene.

    move - is a simple 3d client movement test, use arrow keys and space bar, start with the "ballz" scene.
     

    Attached Files:

  2. hatless

    hatless

    Joined:
    Dec 15, 2010
    Posts:
    16
    I tried the 'tanks' and 'networkstarter' projects and they only spammed error messages. Do these work for anybody else?
     
  3. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  4. aabramychev

    aabramychev

    Unity Technologies

    Joined:
    Jul 17, 2012
    Posts:
    421
    transport layer demo:
     

    Attached Files:

    twobob and ReiAyanami like this.
  5. erebel55

    erebel55

    Joined:
    Jun 14, 2014
    Posts:
    42
    Considering how powerful and advanced Unity is, these samples are pretty disappointing (I know unet was just released).

    At a bare minimum I would like to see something like these
    http://doc.exitgames.com/en/pun/current/tutorials/rpg-movement
    http://doc.exitgames.com/en/pun/current/tutorials/mecanim-demo

    • Player movement smoothing techniques (besides lerping). I'm not sure lerping is a viable smoothing technique. When I have tried using it in the past, it gives an "ice skating" effect, which isn't good for humanoid type characters. I would like to see more about interpolate and extrapolate options (such as with PhotonTransformView).

     
    Last edited: Jun 10, 2015
    d1-favero, IanSmellis, Braza and 3 others like this.
  6. GraphXCreations

    GraphXCreations

    Joined:
    Jul 6, 2014
    Posts:
    121
    well, here is one more complaint, sorry but this dont work.

    i have tried NetworkStarter.zip project and i can only connect with 1 client, the second wont even connect console debug wont throw any errors,
    even raising the max players setting on lobby manager still wont let you connect a secon dplayer.

    I hate to say this but like erebell55 said in the post above the demos are quite disappointing, seems that it is not working for anyone, unless we are missing some steps like saying a magic word before clicking play?
     
  7. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    3
    I can launch Network Starter, I built the game and launched it twice. Host with the first and join with the second. Eveything is fine, movement are the same on the two instances of the game BUT the boxes are not at the same place in each games.
     

    Attached Files:

  8. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    101
    Will there be any examples showing the HLAPI without using the all in one "NetworkManager"?
     
  9. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
  10. Royall

    Royall

    Joined:
    Jun 15, 2013
    Posts:
    101
    Well I am looking for an example where http://docs.unity3d.com/ScriptReference/Networking.NetworkServer.html and http://docs.unity3d.com/ScriptReference/Networking.NetworkClient.html are used similar to the master server sample but instead simpeler without hostlists, but more as a dedicated server setup.
     
  11. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    The NetworkStart projects uses the NetworkProximityChecker on the boxes. So players can only see boxes that are near them.
     
  12. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    130
    Invaders seems to have some pretty major bugs. Everything looks fine on the Server instance, but the client is totally broken, with the enemies scrolling off-screen and the players ship wildly flying all over the place.
     
    FDT likes this.
  13. gilead

    gilead

    Joined:
    Oct 14, 2014
    Posts:
    9
    I'm having trouble using Match maker on Android (both with these example projects and otherwise).

    I loaded up 2dshooter and gave it my Cloud Project Id in the PlayerSettings. If I load the start.unity, run it, click Enable Match Maker, click Create Internet Match, I get success JSON response on the log and the game begins.

    However, if I switch to Android platform, build it up, run it, do the same sequence as above, after clicking Create Internet Match I end up with:

    I/Unity (20567): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)
    I/Unity (20567): Failed to read the ID for the match maker, please set the Cloud Project ID string in the Player Settings (see https://unet.cloud.unity3d.com)
    I/Unity (20567): MatchMakingClient Create :https://mm.unet.unity3d.com/json/reply/CreateMatchRequest
    I/Unity (20567): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)
    I/Unity (20567): System.FormatException: FAILURE Returned from server: FailedCreateMatch for appId=Invalid
    I/Unity (20567): at UnityEngine.Networking.Match.Response.Parse (System.Object obj) [0x00000] in <filename unknown>:0
    I/Unity (20567): at UnityEngine.Networking.Match.CreateMatchResponse.Parse (System.Object obj) [0x00000] in <filename unknown>:0
    I/Unity (20567): at UnityEngine.Networking.Match.NetworkMatch+<ProcessMatchResponse>c__Iterator0`1[UnityEngine.Networking.Match.CreateMatchResponse].MoveNext () [0x00000] in <filename unknown>:0
    I/Unity (20567): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)
    I/Unity (20567): JSON Response: [[UnityEngine.Networking.Match.CreateMatchResponse]-success:False-extendedInfo:Failed CreateMatch for appId=Invalid]-address:, port:0,networkId:0x0000000000000000,nodeId:0x0000,usingRelay:False
    I/Unity (20567): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)
    E/Unity (20567): Create Failed:[[UnityEngine.Networking.Match.CreateMatchResponse]-success:False-extendedInfo:Failed CreateMatch for appId=Invalid]-address:,port:0,networkId:0x0000000000000000,nodeId:0x0000,usingRelay:False
    E/Unity (20567): (Filename: ./artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 65)

    So it seems like I wouldn't have set my Cloud Project Id.. but when I added

    Debug.Log("Cloud Project ID: " + Application.cloudProjectId);

    to the ShooterNetManager.Start() it prints exactly correct cloud project id.

    Any ideas? Anyone tested this with Android? Or iOS or WP8?
     
    Egg_Developer and isidro02139 like this.
  14. Evil-Otaku

    Evil-Otaku

    Joined:
    Oct 17, 2012
    Posts:
    18
    What's missing is the appId. I had to manually set it. Its the UNET ID underneath the Cloud project Id

    NetworkManager.singleton.matchMaker.SetProgramAppID((AppID)XXXXX);
     
    _Adriaan, isidro02139 and gilead like this.
  15. gilead

    gilead

    Joined:
    Oct 14, 2014
    Posts:
    9
    Thanks, that helped with the match maker.
     
  16. RMDKmatt

    RMDKmatt

    Joined:
    Jan 31, 2014
    Posts:
    5
    Has anyone got the new Unity 5.1 Multiplayer features connecting multiple computers over the Internet?
     
  17. gilead

    gilead

    Joined:
    Oct 14, 2014
    Posts:
    9
    Yeah. I'm currently connecting Editor, Android and WP8 over the internet using the match maker.

    Edit: take the 2dshooter project posted above, input your Cloud Project Id (Edit -> project settings -> player) and you should be able to connect multiple desktop clients to each other over the Match maker.

    Connecting Android and WP8 with Match maker seems to currently require SetProgramAppID method call Evil Otaku mentioned.
     
    isidro02139 likes this.
  18. RMDKmatt

    RMDKmatt

    Joined:
    Jan 31, 2014
    Posts:
    5
    I'll give that a try thanks gilead.
     
  19. isidro02139

    isidro02139

    Joined:
    Jul 31, 2012
    Posts:
    63
    Hey everyone, I was wondering if anyone knows of a live-chat (IRC etc.) community where people can share their bugs and experiences with UNET? (specifically for UNET and nothing else). For example, I just discovered that upgrading from 5.1.1p1 → 5.1.1p2 was the reason my editor was crashing when trying to use the free-tier match-making system.

    Thanks!
     
  20. isidro02139

    isidro02139

    Joined:
    Jul 31, 2012
    Posts:
    63
    FYI there is an IRC channel now on irc.freenode.net (#unity3d-unet). Also, some shared resources are gathered here:
    https://goo.gl/UmBBpM
     
  21. isidro02139

    isidro02139

    Joined:
    Jul 31, 2012
    Posts:
    63
    This helped me get my iPhone6 to connect to the multiplayer could via match-maker service! Thank you ^^
     
  22. Olcay

    Olcay

    Joined:
    Jul 1, 2013
    Posts:
    46
    I'm getting these errors on network starter project.

    Create Failed:[[UnityEngine.Networking.Match.CreateMatchResponse]-success:False-extendedInfo:Failed CreateMatch for appId=Invalid]-address:,port:0,networkId:0x0000000000000000,nodeId:0x0000,usingRelay:False
    UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator0`1:MoveNext()
     
    lliviu and macagu like this.
  23. Olcay

    Olcay

    Joined:
    Jul 1, 2013
    Posts:
    46
    And also i cant connect from my own project too which was working fine. Anyone knows the solution or the reason for this issue ?
     
  24. Hyper-Luminal-Games

    Hyper-Luminal-Games

    Joined:
    Jun 24, 2014
    Posts:
    103
    Same issue as Olcay, except works fine for me in the starter project. I cannot get it working at all in my own project. Hidden settings? All I can see is the Cloud Project ID setting.
     
  25. Olcay

    Olcay

    Joined:
    Jul 1, 2013
    Posts:
    46
    At least someone should tell that this is a bug which will be fixed. Or... this problem is an issue about settings or needs an additional thing to do. No one confirms that this online matchmaking is working in webplayer or in multiple PC :S It's only working on editor.
     
  26. Olcay

    Olcay

    Joined:
    Jul 1, 2013
    Posts:
    46
    And also i tried to create a cloud project and build my project there... After a succesful build, still same problem.
     
  27. rikey

    rikey

    Joined:
    Mar 3, 2015
    Posts:
    147
    Error (using Unity 5.1.1p2) when opening 2dshooter project:

    UNetWeaver error: Command [Other:CmdDoMe] parameter [me] is of the type [Transform] which is a Component. You cannot pass a Compent to a Command. Try passing data from within the component.
    UnityEngine.Debug:LogError(Object)
    Unity.UNetWeaver.Log:Error(String) (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:19)
    Unity.UNetWeaver.NetworkBehaviourProcessor: ProcessMethods() (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Weaver/UNetBehaviourProcessor.cs:1263)
    Unity.UNetWeaver.NetworkBehaviourProcessor: Process() (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Weaver/UNetBehaviourProcessor.cs:51)
    Unity.UNetWeaver.Weaver: ProcessNetworkBehaviourType(TypeDefinition) (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:997)
    Unity.UNetWeaver.Weaver:CheckNetworkBehaviour(TypeDefinition) (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1436)
    Unity.UNetWeaver.Weaver:Weave(String, IEnumerable`1, String, String, String) (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1536)
    Unity.UNetWeaver.Weaver:WeaveAssemblies(IEnumerable`1, IEnumerable`1, String, String, String) (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Weaver/UNetWeaver.cs:1605)
    Unity.UNetWeaver.Program: Process(String, String, String, String[], String[], Action`1, Action`1) (at /Users/builduser/buildslave/unity/build/Extensions/Networking/Weaver/Program.cs:33)
    UnityEditor.Scripting.Serialization.Weaver:WeaveUnetFromEditor(String, String, String, String, Boolean)
     
  28. rob.whitten

    rob.whitten

    Joined:
    May 21, 2013
    Posts:
    3
    Is there an example for controlling a prefab from two players. For example, I have a driver and gunner and I want the driver to own control of the driver vehicle prefab's movement but I would like to gunner to update vehicle's turret. Right now I have the gunner using one prefab setup with turret controls and the driver uses a different prefab setup with steering controls.
     
  29. chenyuchih

    chenyuchih

    Joined:
    Jun 3, 2015
    Posts:
    37
    For guys with trouble in opening 2dshooter example.
    Edit Other.cs : Line 80
    public void CmdDoMe(int val, Custom c, Transform me)
    to
    public void CmdDoMe(int val, Custom c)
     
  30. webagency1

    webagency1

    Joined:
    Jun 13, 2015
    Posts:
    9
    Hi! I tried publish move game on Web GL but it is not worked. Does anybody know why?
     
  31. ytrew

    ytrew

    Joined:
    Feb 22, 2013
    Posts:
    18
    Can anyone tell me where to get the updated version of the 2Dshooter. The one found on this forum does not work with regards to syncing bullet movement. It also differs from the Unite talk demo.

    Thanks,
     
  32. webagency1

    webagency1

    Joined:
    Jun 13, 2015
    Posts:
    9
    Does anybody know how to attach camera to the player in multiplayer game? My cameras of different players are mixed...
     
  33. orange_910213

    orange_910213

    Joined:
    Jul 23, 2015
    Posts:
    1
    There are two different computer and the network is different too。One of the PC has created the internet match, but another one can‘t find it.Does anybody know how to solve it?
     
  34. james69lemon

    james69lemon

    Joined:
    Nov 24, 2013
    Posts:
    6
    Since I switched from using the old GUI, to the new GUI system (as used in the NetworkStarter project), The client-player in never instantiated when the game starts. Also, ClientRPC calls are no longer being called on the server. Any ideas here?
     
  35. ian_facepunch

    ian_facepunch

    Joined:
    Mar 16, 2015
    Posts:
    22
    Is there a sample that shows how to use the Matchmaker with LLAPI NetworkTransport?
     
    webagency1 likes this.
  36. chetan-rane

    chetan-rane

    Joined:
    Nov 26, 2012
    Posts:
    17
    i am still not able to connect pc and android together using match maker.
    what wrong i am doing?
     
  37. AubryStrawberry

    AubryStrawberry

    Joined:
    Jul 21, 2014
    Posts:
    4
    Can anyone suggest how to find the IP address being used by NetworkServer.Listen(port) ?
     
  38. james69lemon

    james69lemon

    Joined:
    Nov 24, 2013
    Posts:
    6
    FYI i fixed this by updating to 5.1.2p2
     
  39. rikey

    rikey

    Joined:
    Mar 3, 2015
    Posts:
    147
    Interesting, there was no mention of multiplayer bug fixes in that patch. Maybe updating will fix some of the issues I've been seeing. Thanks for the tip.
     
    james69lemon likes this.
  40. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,138
    The ball sample demonstrates the problem I'm having... desync. Are there any projects that are in sync? The game I'm working on has grid based continuous movements and even minor desync is incredibly noticeable.

    --edit

    2d shooter also has very noticeable desync issues. When a client thrusts, it hits walls first on the server so the client rebounds against nothing.

    Are there any examples with highly synced players?
     
    Last edited: Aug 9, 2015
  41. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    283
    NetworkTransform is pretty useless component. For example there is no way to reach smooth movement with Character Controller. Is it really that hard to provide us with nice and smooth solution, not this jerking bullshit?
     
  42. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,138
    I was going to come back here today and say I solved the issue. I removed the NetworkTransform and synced things manually with Rpc functions. It uses less network traffic and ends up with way better results lol.
     
    twobob likes this.
  43. Glabrezu

    Glabrezu

    Joined:
    Aug 30, 2014
    Posts:
    24
    You can write your own class using almost the same code as the one you see in NetworkTransform, but with your own interpolation in Update. I did it because it currently has no interpolation for SyncTransform, but you can use it as example for your own needs.

    It also serializes some other stuff unrelated to movement (navagent's destination) and has a few other lines that will be useless to your project, but you can just cut them out.
     

    Attached Files:

    twobob and Tomnnn like this.
  44. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,138
    @Glabrezu that's an interesting idea. The issue for me is that interpolation does not look correct in a grid based game :) It causes people to sometimes move diagonally when they should only move in 4 directions.Having an rpc update input and position has the least noticeable desync for grid based movements.

    When I can go back to physics based movements I'll see if networktransform has improved. The issue I saw with all of these demos is that if you take the client and go towards a wall, it always hits the wall first on the server so your client bounces off of nothing. If it's that easy to desync then it's not good :p
     
  45. realvfx

    realvfx

    Joined:
    Jul 5, 2015
    Posts:
    2
    Hi! :) I am trying to modify the lobby example file for my game project lobby system.. everything looks fine and working okay.. but for some reason, the host can see all the clients player game objects but the clients only see themselves and the host ..not each other.. please help !
     
  46. GenaSG

    GenaSG

    Joined:
    Apr 19, 2014
    Posts:
    89
    Hello.
    I've updated to Unity 5.1.3f1 and now I'm getting
    UNet Client Disconnect Error: Timeout
    UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
    error when trying to use network latency simulation. I've tried it on the "move" project.
     
  47. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,138
    UNET still working for me in 5.1.3f1, maybe something got deprecated in the example?
     
  48. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    864
  49. GenaSG

    GenaSG

    Joined:
    Apr 19, 2014
    Posts:
    89
    Could be. But I'm getting similar problem after updating to newer version.
    To be precise I'm getting error described here . First I got it in my project. Then I decided to check if this problem exists in sample projects.
    Too bad there is no fully functional example from unity. I mean client side prediction and server-client reconciliation.
     
  50. Tomnnn

    Tomnnn

    Joined:
    May 23, 2013
    Posts:
    4,138
    What functions are you using? I am able to use syncvars, hooks, client rpcs and commands without issue. That's all I'm really making use of. The built in stuff for other things, like network transform, is way to buggy even in 'stable' versions of unity.