Search Unity

[NO CCU LIMIT] Forge Networking now OPEN SOURCE

Discussion in 'Assets and Asset Store' started by Brent_Farris, Dec 22, 2014.

  1. Leonid

    Leonid

    Joined:
    Aug 20, 2013
    Posts:
    90
    Ok, just bought Forge!
    Thanks for great work!
     
  2. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, doesForge Networking work on mobile platforms? Can it handle NAT problems? Thanks.
     
  3. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    I am making a car game but it laggs like hell xD

    What should i put in frame interval and what in update time interval?
     
  4. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello! Sorry for not getting an answer to you on your last post. Yes, in our demo we actually have a "Find on LAN" button where no IP address is needed and the client will broadcast a message on the local network where then the hosting game server will respond causing the client to connect to it :)
     
  5. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Forge Networking was built with mobile in mind and works on those platforms. Furthermore Forge will work on any platform that Unity supports that supports .NET Sockets as well as WebGL with our websocket implementation. NAT hole punching is built in but it is legacy, the new Remastered version will support NAT hole punching natively. :)
     
    zhuchun likes this.
  6. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    This could be a couple of things, the lag may be due to not using interpolation, not having the sync time fast enough, or possibly Unity's non-deterministic physics simulation causing things to have to correct too often. We may need some more context, are you on Slack or Reddit? I ask because to help more context will be needed and may go beyond the scope of this thread. :)
     
  7. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Yea i am on slack but i quess no-one is online because no-one helps XD
     
  8. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Not sure if someone answered this already, but yes lan discovery will work with hotspot
     
  9. CyberMew

    CyberMew

    Joined:
    May 18, 2013
    Posts:
    23
    How do we get access to github?
     
  10. HectorSilva

    HectorSilva

    Joined:
    Jun 20, 2015
    Posts:
    20
    Hi, Farrisarts.

    I want my 2D quiz App allows users of a classroom (each possibly with different devices: ios, android, PC, WebGL) to compete in a networked quiz. I see Forge can accomplish things more complex than this, but I do not know if it's the right tool for what I need (just simple string messages between users), I'm looking for the easiest and functional tool .

    This is what I want to achieve:
    1) The teacher asks students to enter the app and choose an option for networking game, students do,
    2) As each student enters, his name appears on a list in the master device,
    3) Once all students have entered, the master sends a message for start competition,
    4) As students are answering questions, his devices sends his progress to the teacher device.

    Can this be achieved with Forge?
    Among the examples is there one that performs a similar task?
    Or what steps involved this task in Forge? (roughly)

    Thank you in advance!
     
    Last edited: May 29, 2016
  11. motion-art-game

    motion-art-game

    Joined:
    Dec 17, 2015
    Posts:
    24
    thanks for reply.
    let me buy it as my purpose is solved for LAN.
     
  12. NINJAAA

    NINJAAA

    Joined:
    May 27, 2015
    Posts:
    7
    How can i send or synchronize material(with texture) in unity using Forge Networking?
     
  13. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    You can request it from farris arts
     
  14. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Yes, it definitely can.
    No, there are extensive tutorials for forge and the WriteCustom I think will be particularly useful.

    Generally the structure of forge is very similar to most networking solutions. You have both of the popular methods (message system - WriteCustom in forge, and RPCs)

    You'd want to watch our tutorials first, then plan what data needs to be sent to each client when, then simply design the ui, and write the RPCs or WriteCustoms to apply the desired effects.
     
  15. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    A material cannot actually be serialized as it is a unity class. You want to serialize the desired properties, receive/send them across the network, create a new material and apply the desired properties.

    You can however by serializing the texture data. You can use
    http://docs.unity3d.com/ScriptReference/Texture2D.EncodeToPNG.html

    And then send the byte[] across the network.
     
  16. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Please request it to me in a PM on Slack, my username is "BrentFarris"
     
  17. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Another option is to have your material pre-defined in a list or lookup table. Then send the index of the item you wish over RPC and do the lookup and assignment from there. You can however send a texture over by getting the byte[] associated with it with something like http://docs.unity3d.com/ScriptReference/Texture2D.EncodeToPNG.html :)
     
  18. NINJAAA

    NINJAAA

    Joined:
    May 27, 2015
    Posts:
    7
    L
    [QUOTE = "FisherM, должность: 2654941, член: 513989"] Материал не может быть фактически сериализовать как это классовое единство. Вы хотите сериализовать желаемых свойств, получить / отправить их по сети, создать новый материал и применить желаемые свойства.

    Однако вы можете посредством сериализации данные текстуры. Вы можете использовать
    http://docs.unity3d.com/ScriptReference/Texture2D.EncodeToPNG.html

    А затем отправить байт [] по сети. [/ QUOTE]
    Большой! Я получил его, но как я могу отправить renderTexture (как потоковое)?
     
  19. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Yes, if you can get the data for the render texture in bytes then you will be able to send the data. I used Google Translate to get the English translation, please let me know if this is the appropriate answer :)
     
  20. NINJAAA

    NINJAAA

    Joined:
    May 27, 2015
    Posts:
    7
    Greatings! Can you show me The whole code please?
     
  21. NINJAAA

    NINJAAA

    Joined:
    May 27, 2015
    Posts:
    7
    Can you give me an example of net synchronizing the texture of the material through the stream using forge networking?
     
  22. kriket

    kriket

    Joined:
    Aug 28, 2014
    Posts:
    33
    If you know forge (I still have to buy and learn how to use it), how hard will it be (networking beginner but experienced dev) to build and maintain a low-latency realtime multiplayer game in the vein of agar.io or slither.io with Forge on top of a headless server say at linode. I have checked out your headless server vid but things can get complicated fast at scale. Of course, when a game starts to get 100,000 MAUs one can look into hiring an expert but I would like to do as much as I can (and hopefully make some profit to hire someone) before even thinking bout bringing another person in.

    Looked at gamesparks and playfab, and of the two I prefer playfab cos of their awesome support, but just wanted advise from guys who just try and handle networking from a pure API side of things and dont provide cloud hosting themselves.

    Thanks
     
  23. AlterSpace

    AlterSpace

    Joined:
    Jun 29, 2014
    Posts:
    34
    So, for the very last question before the purchase... I would leave the dedicated service, of my previous questions, for a second moment (at least after playing a little more with linux server programming at home).
    My objective is to make a multiplayer game for 8 players, to release on Steam and using the Steamworks system to use the lobbies architecture offered by Steam back-end server.
    So, finally, the question: is there some kind of NAT punchtrhough with Forge? Can I connect the different clients and host using a direct IP connection?
     
  24. witcher101

    witcher101

    Joined:
    Sep 9, 2015
    Posts:
    516
    Hi
    Does this work with webgl. can i connect with anothrer user through browser
     
  25. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    I do not have one off hand. Basically all you will need to do is get the byte[] that represents the texture, then simply pass that byte[] to an RPC and then in the RPC convert the byte[] back to a texture :). If I get some time we will make a tutorial on something similar to this so that we can share it with everyone.
     
  26. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Forge is a framework so you can layout your architecture for the network in the way that suits you best. You can have servers communicate with each other and the various clients, passing them from one server to another (zoning) or you can have it so that there is a master server that is tracking all of your servers, and you have different servers that the player connects to without hopping between them. It also depends on if you have the capital to scale up (beefier servers) or to scale out (more servers / distributed computing). As stated, Forge Networking is just a framework to handle the network communication, you can scale it as far as you wish :) especially since you have full source code and you are an experienced dev :D
     
    kriket likes this.
  27. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Forge Networking Remastered (which will be free to Forge Networking owners new and old) will have a NAT hole punching server. Forge Networking itself has NAT hole punching built in but it has not been extensively used. Of course with full source code you could also create the hole punching server in the old system if the current one does not suffice :)
     
  28. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Yes, we support Websockets (WebGL) :). A note though, servers can only be hosted outside of the browser, no web browsers will allow you to host a server in them, so though players can play with each other in the browser, they can not host a server in the browser. This is a hard limitation that browsers will not ever change, so hosting of game servers (that clients ran in the web browser connects to) will be done on any other supported platform. :)
     
  29. wahyuway

    wahyuway

    Joined:
    Oct 7, 2013
    Posts:
    84
    hi, i bought forge master server addon. Is there any doc about forge master server command?
    i tried to launch forge master server locally and tried to connect to it in editor unity. But no it said no server.
    I also tried to upload to my ec2 server still no luck to connect to it. all required ports already added to my firewall. Other server also works well (i use photon server).
    any suggestion? tks
     
  30. NINJAAA

    NINJAAA

    Joined:
    May 27, 2015
    Posts:
    7
    HEY! I heve found a bug! Why my client does not see sended bytes? I tryed to send string and It worked! Unfotunately I think this problem in plugin!
     

    Attached Files:

  31. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hi there, the tutorials for the Master Server can be found here. This is for the built in master server but work relative to the Independent Master Server. One thing you can do when the master server is running is type "show log" in the command line. The master server does require for your port to be open (default is 15940).
     
  32. NINJAAA

    NINJAAA

    Joined:
    May 27, 2015
    Posts:
    7
    Code (CSharp):
    1.  
    2. public class NetworkController : NetworkedMonoBehavior {
    3.  
    4.     public Material clientsMaterial;
    5.     private NetWorker socket=null;
    6.     public bool isClient;
    7.     void Start()
    8.     {
    9.         Networking.InitializeFirewallCheck(15937);
    10.  
    11.         if (isClient) ConnectToServer();
    12.     }
    13.     public void StartServer()
    14.     {
    15.      
    16.         socket = Networking.Host(15937, Networking.TransportationProtocolType.UDP, 31, false, "", true, true);
    17.         Networking.SetPrimarySocket(socket);
    18.     }
    19.     public void ConnectToServer()
    20.     {
    21.      
    22.         socket = Networking.Connect("127.0.0.1", 15937, Networking.TransportationProtocolType.UDP,false);
    23.         Networking.SetPrimarySocket(socket);
    24.     }
    25.     public void StopServer()
    26.     {
    27.         if (socket != null)
    28.         {
    29.             Networking.Disconnect();
    30.             socket = null;
    31.         }
    32.     }
    33.     public void SendRenderData(Texture2D tex)
    34.     {
    35.         if (tex != null)
    36.         {
    37.             tex.Resize(1024,512);
    38.             byte[] _data = tex.EncodeToJPG(50);
    39.             RPC("GetTextureData", _data);
    40.         }
    41.     }
    42.     [BRPC]
    43.     private void GetTextureData(byte[] data)
    44.     {
    45.         Debug.Log(data.Length);
    46.         if (isClient)
    47.         {
    48.             Texture2D texture = new Texture2D(2, 2);
    49.             texture.LoadImage(data);
    50.             clientsMaterial.mainTexture = texture;
    51.         }
    52.     }
    53.     void Update()
    54.     {
    55.         if (socket != null && socket.Connected)
    56.         {
    57.             Debug.Log("Conected");
    58.         }
    59.     }
    60. }
    61.  
    This is my code
     
  33. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    I think this code is doing things that I just don't fully understand. Anything that Derrives from a NetworkedMonobehavior is something that will be part of a socket connection if that exists. It seems that you are creating a separate socket on an already existing socket connection as well.
    Can you please try using the QuickStartScene provided and then just do the RPC code when it has loaded the scene with this script in it? Then remove the socket creation process on this script and see if that helps.
     
  34. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    forge master server addon? what? where is more info on this?

    is remastered coming with that?
     
  35. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    The Independent Master Server is the same as the documented master server on the website. This is a server that runs without the overhead of a Unity instance so it is the production ready server.

    The Unity Independent Master Server addon will be updated for Forge Remastered, yes :). It will not be bundled with it, just updated to support it, so the pricing and purchase model stays the same.
     
  36. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    What is the pricing on it? Everythings all walled up at your Forge website.
     
  37. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Sorry about that, a lot of our features are features are for members and seeing the full list of addons is one of them (at the moment). The Unity Independent Master Server is a 1 time purchase of $4.99 :)
     
  38. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Announcement - Madness Sale Last Day!

    Today is the last day of the Madness Sale. We do not have any plans to go on sale again in the near future because of the upcoming release of Forge Networking Remastered (which you get for free if you are a Forge Networking owner, including if you purchase any time before it's release *including during this sale*).

    Get em' while they're hot! We'll see you in the community :)
     
  39. NINJAAA

    NINJAAA

    Joined:
    May 27, 2015
    Posts:
    7
    Thanks for the help! I do not want to use QuickStartScene stage. I was rejected from the forge networking and currently use unet
     
  40. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Can you explain what you mean by you were "rejected" from Forge Networking, I assume this has something to do with the language conversion from Russian to English that I have seen previously?
     
  41. Red_Kay

    Red_Kay

    Joined:
    Aug 14, 2015
    Posts:
    94
    Is there any way of implementing room based system with Forge? If there is can tell me?
     
  42. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    This is a bit of a big question. I suppose the easiest way that I can put this is that you need to code a system where you can separate players into something like lists or dictionaries. You can also use the MessageGroup which is a part of the NetworkingPlayer. After you separate out the players you will want to send messages to that group of users, in this small scenario they are effectively in "rooms" since they are all on the same server IP/Port and only send messages to those in the group. There is actually more game or program logic then actual networking logic luckily :).

    We have some tickets related to this question and Forge Remastered as well :)
     
  43. Leonid

    Leonid

    Joined:
    Aug 20, 2013
    Posts:
    90
    Hi guys!
    Help me please.
    2 questions:
    1) I want to get scene name which is running on lan server, how can i do this?
    Or is there any other way to connect to the server not knowing scene name?
    2) When i start server from scene with networkedMonoBehaviours GameObjects on it I get an error "
    ArgumentException: An element with the same key already exists in the dictionary.
    System.Collections.Generic.Dictionary`2[System.UInt64,BeardedManStudios.Network.SimpleNetworkedMonoBehavior].Add (UInt64 key, BeardedManStudios.Network.SimpleNetworkedMonoBehavior value..."
    .
    Is there any way to fix it?

    Thanks!
     
  44. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    Hello Leonid,

    1) You can always connect to some type of Master Server or Host and have the host send an RPC of the current scene as a string back to the client that connected.
    2) That's an interesting error, are you using the latest and by chance can you double check the Networking Manager to make sure no duplicates are added there as well as the resources folder. Just make sure there is no networked objects with the exact same name.

    Let me know if this helps.
     
  45. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Hey,
    1) depends on your version of unity, if you are pre 5.3, you'll use Application.LoadedLevelName
    https://docs.unity3d.com/ScriptReference/Application-loadedLevelName.html

    or
    https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.GetActiveScene.html
    if you are using 5.3 or latter.

    You can then send the scene name as a string to clients on request if need be.

    see my example:
    Code (CSharp):
    1. void Start(){
    2. RPC("getSceneFromServer", NetworkReceivers.Server);
    3. }
    4.  
    5. [BRPC]
    6. public void getSceneFromServer(){
    7. RPC("setServerScene", Application.loadedLevelName);
    8. }
    9.  
    10. [BRPC]
    11. public void setServerScene(string scene_name){
    12. Debug.Log("Server is currently on scene "+scene_name);
    13. }
    14.  
    2) Will direct message you to see if that is a bug or an issue with your setup.

    Thanks
     
  46. Leonid

    Leonid

    Joined:
    Aug 20, 2013
    Posts:
    90
    Thanks for reply.
    I'm new to Forge, so can you please describe this solution in detail?
    I assume this is quiete frequent question, so maybe there is some tutorials / examples?

    I'm using v20, of course i'll check if there is some duplecates.
     
  47. Leonid

    Leonid

    Joined:
    Aug 20, 2013
    Posts:
    90
    Thanks for reply.
    So my client should first connect to server and then load the scene?
    Honestly i cant imagine how to implement this solution.
    Is there any way to modify StartGame script to achieve my goal?
     
  48. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    To send a message to a server you must connect to it first. The alternative is to have a master server which has a connection to the server. The master server can then give data about the game server to a client.
    See the master server tutorial for information on that.
     
  49. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    hi i just purchased the addon ' Unity independent master server' Is there any documentation on this?
    list of commands or alike

    EDIT: Ahh think i have found it in the Documentation 'Master Server'


    This is actually referring to building a unity Mast Server. Does this apply to the Addon pack Master Server?

    Thanks
     
  50. djgriff

    djgriff

    Joined:
    May 29, 2014
    Posts:
    279
    Hi i am also following your tutorials and i have declared using NetworkMonobehaviour, but when i try to override the update(); it states ' There is no suitable method to override' ?

    advice on this would be great..

    I am trying to update my character movement script.

    Thanks