Search Unity

[NO CCU LIMIT] Forge Networking now OPEN SOURCE

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

  1. Sorcerak

    Sorcerak

    Joined:
    May 19, 2013
    Posts:
    7
    Just bought this package in order to use it with an authoritative server way. Already started to customize the commands to support the gyroscope directions.

    I am concerned on the security side of things: At first glance it seems like clients can send instantiate prefab commands as they wish and are being replicated by the server automatically. Or am I missing something? How can I block a rogue client from sending several game objects?
     
  2. phil-harvey

    phil-harvey

    Joined:
    Aug 27, 2014
    Posts:
    75
    ok, so have a small issue.

    During the course of a game, I'm having the server create a lot of objects with this

    Networking.InstantiateFromResources("model1", new Vector3(0.0f, 0.0f, 0.0f), quat, NetworkReceivers.AllBuffered);

    It works great all machines see the objects, when the are moved around via the server. The buffering is working fine.

    When the object is killed, I'm killing it with

    Networking.Destroy(obj);

    Which again is good, all current clients will see the object destroyed correctly,

    But now the issue. Any future clients which are connecting now see all the objects being created, even the ones which have been destroyed. And hence they are now just scattering the ground on the new clients. How can I have it so that when they are created everyone sees all of the objects, but when they are destroyed they are then removed from the buffered stream, so that people cannot see their creation.

    Phil
     
    DavidMilot and CarterG81 like this.
  3. Deleted User

    Deleted User

    Guest

    Hi, im just planing to buy Forge, but i have several questions.

    1. Can i have as a Client a connection to two servers parallel? (I want to seperate the chat to an external forge server without any unity logic, will be something like a masterserver)

    2. Can i synchronize physics, like vehicles?

    3. Are there any limitations on, how many players can play on one server?

    4. Is there a built in solution for an area of interest / point of interest?

    5. Can i serialize a byte array or only a byte?
     
  4. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    Hi, Quick question. Does this work with steam ? I am looking for package to support multiplayer.
     
  5. GlobalHive

    GlobalHive

    Joined:
    Jan 13, 2014
    Posts:
    18
    I am using it with Steam, i just dont use the Steam networking stuff since fort thats Forge here :D
    So it is working ^^
     
  6. roychr

    roychr

    Joined:
    Jun 16, 2009
    Posts:
    33
    Im sorry I fail to actually see anywhere information if I can use code i.e. use an API to start / stop a specific server in the offered cloud service ON DEMAND to create separated server side instances. Like I said I understand I can just take as many servers as I want, but my question is : Can I Start/Stop new instances dynamically.
     
  7. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Since all messages are sent through the server and clients do not send messages to each other that means that you can then validate any messages sent to the server to make sure it is a valid request. With the server you will be able to read the message that was sent by the client and determine if it is valid commands. There are a few places in the server code where you could intercept messages from the client doing these requests. In the Networking class you will notice that the instantiate is a wrapper around the NetworkingManager.Instantiate. So from the NetworkingManager.Instantiate you can actually intercept this call on the server and do any exception handling that you need to do for the client. If you wish for further information or you want to see some source code, please send us an email to support@beardedmangames.com :)
     
  8. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hi there Phil! So you can actually call a buffered destroy on the network in order to regulate this. However since you are doing this many times it seems like you will need a better clearing mechanism for the buffered RPC calls. We will begin working on this feature ASAP. Of course, since you have the source code if you want to fiddle with some ideas of your own on how to limit it feel free. :) We will get this to release as soon as possible!
     
    DMeville likes this.
  9. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Awesome! Thank you so much for your support!

    Yes, you are able to open up multiple sockets with the Networking.Connect method that is built in. This will allow you to connect to multiple servers from one client and even allow servers to connect to other servers as a client.

    Yes, since Forge mainly works in a Unity instance you have all of the standard Unity Physics and any other systems at your disposal :D

    No, you can in theory have as many players as you want. The real limitation is how much your hardware can handle :) We technically have a hard limitation of 18,446,744,073,709,551,615 clients :) (size of a ulong, which is what we use to track players)

    Yes, we call this proximity, just click the "isPlayer" checkbox on your player prefab that has a NetworkedMonoBehavior and then click the "proximityBasedUpdates" checkbox on the StartGame script

    You can send messages across the network with WriteRaw, WriteCustom, or RPC.
    • WriteRaw will allow you to be able to send raw bytes across the network with a 1 byte header This will support a byte array
    • WriteCustom will allow you to serialize entire classes and large data structures very easily. This will support a byte array
    • RPC will allow you to send a one byte argument to a function if you wish, however it does not support a byte array yet.
     
  10. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    As far as I know, sockets work as they normally do in Steam, as Steam doesn't do anything different with the network. There is the Steam SDK which will allow you to get users and such, however that is separate from the actual network communication which Forge focuses on. :) Please let me know if you need further information.

    EDIT:
    Oh thanks for the verification! :D
     
  11. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    Yes!

    And we also plan having a UI inside unity for it. :)
     
    roychr likes this.
  12. Deleted User

    Deleted User

    Guest

    Thanks @farrisarts, i bought it :)

    Is it possible to get the Bare Metal Beta? So i can implement my own Login Server and Master Server with an integrated Chat.
     
  13. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    Hi @Synter Games,
    That sounds cool. Did you guys used steam match making for the same ? is it possible to handle to match making in steam API and use the players in steam lobby to connect to Forge ?
    And also would like to know whether we can build p2p type networking and host migration with the same ?

    @farrisarts ,
    Got any idea how to integrate Forge with steam matchMaking APIs ! Planning to create P2P racing multiplayer with host migration. Does forge support Host migration ?
     
    Last edited: Jul 28, 2015
  14. GlobalHive

    GlobalHive

    Joined:
    Jan 13, 2014
    Posts:
    18
    well we just use it to connect one player with another for our co-op mode.
    We dont really use much from steam just saving the game process and achievements.

    But since i am using Steamworks.NET i could get the friendlist and with that the connection to an game i guess. (never tested it)
     
    Last edited: Jul 28, 2015
  15. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Announcement
    We have sent out a mass email to invite everyone who has purchased Forge Networking to our Slack chat channel. This includes anyone who purchased from the website or anyone who purchased from the Asset Store and registered their invoice number through the website. Here you can share files, chat and create various private and public chat channels as well as send private messages. Lets continue to build a strong community and get to know each other :)
     
    tatoforever likes this.
  16. equimor

    equimor

    Joined:
    Feb 19, 2014
    Posts:
    8
    Hey farrisarts! I have been following Forge since the beta, and i must said that i am more than interested on purchase, it seems amazing :)

    A couple of questions if you don't mind ;)
    1. Can be possible to use a model where the users register the servers at the master server because i am developing a fighting game and i need game server sessions created and destroyed by the users themselves.
    2. Can be too dificult adapt forge to save and read data from mysql maybe with php scripts, to store all the data to the server side? i have been reading the entire thread but i can found nothing related to this.

    I looking forward for your answers :3

    Cheers!!!!
     
  17. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    Slack has been very convenient for us all and glad to have everyone using it. We will be updating our tutorials and have a new demo showcase soon!! For those that are joining in the forge community, definitely join us on the chat group so that you can have your questions answered alongside like minded developers.
     
  18. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    1. Absolutely, currently that is what the master server does. :)

    2. From what our developers have done they haven't had any problems connecting to a database for saving/loding data. Feel free to join the chat and ask advice from people who have done it if you need help. Otherwise we'll be here to provide the support on that.

    Glad to know you have been following our thread. We've come a long way from where we were at up till now. A lot has changed and there is bigger and better things to expect coming forward. :D
     
  19. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    Just wanted to thank you all again for being huge supporters of us. I know that some other networking solutions are having problems with IL2CPP and are waiting for Unity to solve their issues when it is really not their fault. Thankfully we are happy with the direction unity has been taking and been on their toes ever since they have been dealing with iOS. We have no issues on iOS to report and are happy to say that other users haven't had any issues relating to those devices yet! So please do bring your amazing games to the best networking solution on the market and we will do our best to craft it towards your needs and goals!

    With awesome support on our Slack channel, we are able to bring all like minded developers to one community that is passionate about multiplayer games.

    This is the solution for your multiplayer problems, don't make the mistake of thinking other ones will fix it for you in a timely period where you need it most.
     
    elias_t likes this.
  20. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    Hey there,
    Any idea why Networking.Instantiate is not working?
    I'm trying to instantiate a player from a server.
    Adding NetworkingManager only creates errors.

    What should be done for instantiating to work?
     
    Last edited: Jul 30, 2015
  21. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    With NAT hole punching you can support host migration, we have a currently working "experimental" version of this in 10.9. As for using the Steam API for matchmaking I would imagine it wouldn't be difficult. We do not have this out of the box, but we will now look into it, it is quite possible that Forge will not need to change anything, just add a few scripts to support the API.
     
  22. b889965

    b889965

    Joined:
    Oct 10, 2014
    Posts:
    8
    I Think you mean Networking.Instantiate not Initialize.
     
  23. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    Yes, your right.
     
  24. CineTek

    CineTek

    Joined:
    Jul 12, 2013
    Posts:
    98
    I have been looking into Steamworks integration all day long and was able to technically include things like creating a lobby and inviting friends through the overlay quite easily within an hour or so. BUT as long as your game is not on Steam or has not been greenlit yet then there are some strict limits in using it. You can do some stuff like using Steam names but the whole matchmaking service for example is not usable as long as you do not have your very own unique AppID.
     
  25. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    What resources you were using to find the info? I had hard time figuring out steamworks because of strange documentation. I have an AppID so that wont be an issue
     
  26. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    I am assuming that you are meaning Networking.Instantiate? Also, do you have the latest version? 10.9. You can get it from the website :)

    http://developers.forgepowered.com/...nityAssetStore/How-to-Register-Invoice-Number
     
  27. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    @CineTek
    I am interested in this too so that we can get the ball rolling on some tutorials or integration helpers ourselves for the system :)
     
  28. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
  29. CineTek

    CineTek

    Joined:
    Jul 12, 2013
    Posts:
    98
    Brent_Farris likes this.
  30. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    The NetworkingManager is required as it is a wrapper class for communicating common behavior to unity. The new version does have bug fixes related to instantiation, connections and disconnections.
     
    moure likes this.
  31. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    When adding NetworkingManager by hand I get alot of:
    NetworkException: The base class "Start" method is hidden, use "protected override void Start" instead and call base.Start() at the beginning of the function.
    BeardedManStudios.Network.NetworkedMonoBehavior.Update () (at Assets/Bearded Man Studios Inc/Forge Networking/MainScripts/NetworkedMonoBehavior.cs:651)
    MultiplayerLobbyScript.Update () (at Assets/MultiplayerLobbyScript.cs:44)

    But I've noticed if it isn't present it automatically creates it and then it works without issues, but how am I supposed to assign game objects to it at runtime?

    I have tried this:

    GameObject netMgrObj = GameObject.Find ("Networking Manager(Clone)");
    NetworkingManager netMgr = netMgrObj.GetComponent<NetworkingManager> ();
    netMgr.networkInstantiates = new GameObject[0];
    netMgr.networkInstantiates[0] = (GameObject)Resources.Load("Player/Prefabs/PlayerMP", typeof(GameObject));
     
  32. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    This NetworkingManager is spawned from a prefab. You can later the prefab if you wish, or you can drag this prefab into your scene and alter it then. :) Please let me know if this works.
     
  33. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    Putting prefab into scene creates all these "use "protected override void Start"" errors, but it works when it automatically creates it. I have managed to assign instantiates dynamically from code as a workaround, but I believe either it is a bug or I'm doing something wrong when adding the prefab by hand.
     
  34. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    This is not an error, it is a warning. Simply just call the Base.Start() in your Start() in order to clear up any warnings when you are derriving from SimpleNetworkedMonobehavior or NetworkedMonobehavior.

    We will have it fixed in the next update.
     
  35. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    I'm calling it + base.awake and base.update in respective methods, yet it still occurs.
     
  36. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello :) it may be because you are putting the NetworkingManager into a scene before your connection has ever been established. You will need to put the NetworkingManager into the scene that you will be moving to once you have established a connection. The NetworkingManager will throw this exception when it can not find an established network connection.
     
  37. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    Ok, thanks for help guys. I'm finally making progress with my first multiplayer game thanks to your awesome library :)
     
  38. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    @Neomex Are you a part of our Slack chat channel? :) If not we can get you added so that either us or the community can answer your questions super fast. If you would like to be a part of this, please just shoot us an email to support@beardedmangames.com :)

    EDIT:

    Oh awesome!! Please let us know if you have any more questions.
     
  39. CineTek

    CineTek

    Joined:
    Jul 12, 2013
    Posts:
    98
    @Neomex If you need any help with the Steamworks.NET setup and coding just give me a shout on Slack. I can show you what I got so far in my implementation.
     
    CarterG81 likes this.
  40. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    Email sent :)

    In meantime, what to do if I need to serialize enum? It says its not yet supported.

    Also, small suggestion, could you make Networking.Instantiate return GameObject? It would allow for a more Unity like styled programming instead of making all those callbacks.

    I need to pass a variable to the callback so I've tried doing it this way, but I'm not sure if it is proper way of calling lambdas:

    Code (csharp):
    1.  
    2. for(int i = 0; i < shotgunBulletCount; i++) {
    3.              Networking.Instantiate(shotgunBullet, transform.position, Quaternion.identity, NetworkReceivers.All,
    4.               (GameObject o) => {
    5.                ApplyBulletVelocity script = o.GetComponent<ApplyBulletVelocity>();
    6.              
    7.                Vector3 normal = new Vector3(Random.Range(-1.0f, 1.0f), 0, 0).normalized * Random.Range(0.0f, shotgunAngleStep);
    8.                angleStep = normal.x;
    9.              
    10.                script.force = CalculateDirectionForce(angle - shotgunBulletCount / 2 * shotgunBulletSpaceAngle + i * shotgunBulletSpaceAngle + angleStep, shotgunBulletForce);
    11.  
    12.              });
    13. }
    14.  
    I get this error when I do so:

    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. BeardedManStudios.Network.NetworkingManager.PullObject (System.String name) (at Assets/Bearded Man Studios Inc/Forge Networking/MainScripts/NetworkingManager.cs:267)
    4. BeardedManStudios.Network.Networking.ValidateNetworkedObject (System.String name, BeardedManStudios.Network.SimpleNetworkedMonoBehavior& netBehavior) (at Assets/Bearded Man Studios Inc/Forge Networking/MainScripts/Networking.cs:589)
    5. BeardedManStudios.Network.Networking.CallInstantiate (System.String obj, Vector3 position, Quaternion rotation, NetworkReceivers receivers, System.Action`1 callback) (at Assets/Bearded Man Studios Inc/Forge Networking/MainScripts/Networking.cs:630)
    6. BeardedManStudios.Network.Networking.Instantiate (UnityEngine.GameObject obj, Vector3 position, Quaternion rotation, NetworkReceivers receivers, System.Action`1 callback) (at Assets/Bearded Man Studios Inc/Forge Networking/MainScripts/Networking.cs:699)
    7. BulletSpawnerMP.FixedUpdate () (at Assets/BulletSpawnerMP.cs:820)
    8.  
     
    Last edited: Jul 31, 2015
  41. alecie

    alecie

    Joined:
    Sep 2, 2013
    Posts:
    73
    Thanks! I'll reach out to you when I get to steamworks side of things.
     
  42. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    You can cast the enum as an int as this is it's native data type and then replicate this value across the network.

    We do not do this because we run multithreaded and so we do not holt the main thread during a game object's creation response from the server. I don't believe that Unity cares about authoritative servers so they just spawn it on the client and demand that the server should comply (or they just holt the thread). We request it from the server and only do it if the server allows it.

    You will just need to have the variable within the scope of the callbacks scope in order to use it there. :). Here is an untested snippet.

    Code (CSharp):
    1. private void DoStuff()
    2. {
    3.     // This is function scope
    4.     int x = 0;
    5.    
    6.     for (int i = 0; i < 10; i++)
    7.     {
    8.         // This is for loop scope
    9.         int y = i;
    10.        
    11.         Networking.Instantiate(myThing, pos, rot, NetworkReceivers.All, (GameObject o) =>
    12.         {
    13.             Debug.Log(x + ", " + y);
    14.         });
    15.     }
    16. }
     
  43. p627

    p627

    Joined:
    Apr 12, 2014
    Posts:
    23
    I make a new multiplayer game so i decide to use photon but the problem with photon is the CCU and the highs prices.. so i search again and i found your tool without CCU and in a good price. My question is i need windows server or linux to open ip-port? because all the video use localhost is there any video to explain how to do that or can u explain me?

    thank you.
     
  44. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello! :) you are in good company, many of our users come from Photon

    Localhost examples work the same as IP and Port normally. If you replace any of our tutorials "localhost" "127.0.0.1" with the IP you choose then it should work fine. We have NAT hole punching in an experimental state in the current version but as it is in most all mainstream games you can open up the port to your server to access it remotely :)

    Please let me know if you have any further questions or need more assistance on this :)
     
  45. p627

    p627

    Joined:
    Apr 12, 2014
    Posts:
    23
    so can i open port and host my game in my CentOS server or need ubuntu server?
     
  46. b889965

    b889965

    Joined:
    Oct 10, 2014
    Posts:
    8
    That depends on which packets you have installed on your CentOS server. You need Mono and i believe there are few more packets to run a unity linux build in batchmode.
     
  47. Shaka

    Shaka

    Joined:
    Apr 24, 2010
    Posts:
    51
    Hello!
    In an earlier post you said it's possible to send RPC:s to a specific player (using the id or NetworkingPlayer object). I'm a bit new to this so I'm still getting my bearings, but I can't seem to figure out how to do that. Any advice?

    [EDIT]
    Another question. I can't seem to get WriteRaw to work (Server->Client).
    I have gameobject in my scene with a script that sets this event in Start() for the client.

    Code (csharp):
    1. Networking.PrimarySocket.rawDataRead += OnReadRawData;
    Event handler looks like this:
    Code (csharp):
    1. private void OnReadRawData(NetworkingPlayer sender, BMSByte data)
    Then from the server I call WriteRaw like this from a script:

    Code (csharp):
    1. Networking.PrimarySocket.WriteRaw(networkingPlayer, data, "SendGameState");
    But OnReadRawData is never called on the client (networkingPlayer). Any clues?

    Regards/Per
     
    Last edited: Aug 2, 2015
    CarterG81 likes this.
  48. Mikael-Madrid

    Mikael-Madrid

    Joined:
    Nov 2, 2012
    Posts:
    26
    Hello,I'm wondering how much is the delay when Clients connect to a Server(not hosted by any of the players).
    Basically I really wanna buy this but I'm concerned about delay issues in Real Time games.(I'm aware lots of things can come into play here like connection speeds and hardware).
    Thanks in advance!
     
  49. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    @CineTek,
    Our Racing game is greenlit and i would like to use Forge for multiplayer module of the game. Just wanted clarify how easy it is to implement Host migration or is it already implemented in Forge.
     
  50. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    Hey Sathya! I believe I answered your email that was sent to us. If you have any other questions feel free to email me back again as well as ask any of our other developers questions here. :)