Search Unity

[NO CCU LIMIT] Forge Networking now OPEN SOURCE

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

  1. meminmamon

    meminmamon

    Joined:
    Mar 30, 2014
    Posts:
    5
    Hi, I've just purchased Forge and So far I have been able to get my game networked locally:) Now I want to make my game run on a cloud server like Google Cloud or Digital Ocean(Can you recomend me one?) and allow a big number of clients (arround 500) to connect to that server. I'm not sure how to do this but my hunch tells me that maybe I can modify the "Host" and "PlayerCount" variables from the "StarGame.cs" that came with Forge for the right values and that will do the job. Is this correct? or should I have more stuff in account? also that "PlayerCount" has a limit? what happen if it's reached? thanks in advance for any guidance.
     
  2. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    You no longer need to override the update method, just call Update() as usual
     
  3. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    So, you can set the PlayerCount as high as you like, to actually run 500 players will require a lot of optimization, or potentially having players connect to different servers based on where they are on the map. If the limit is reach connections will simply be rejected and the client won't be able to connect.
    You'll want to run unity in headless mode on a cloud server, Google Cloud and Amazon Azure are both very solid options.
     
  4. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Yes, the Master Server tutorials are referring to the addon.
     
  5. PunkCG

    PunkCG

    Joined:
    Sep 8, 2015
    Posts:
    4
  6. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    DM'ed you
     
  7. KarloE

    KarloE

    Joined:
    Aug 26, 2013
    Posts:
    175
    A question - where is the best/cheapest place to host a forge server once you start development and want to test out the game with colleagues? I am interested in this networking solution and trying to figure out if I should use it or not.
     
  8. PunkCG

    PunkCG

    Joined:
    Sep 8, 2015
    Posts:
    4
    AWS is reliable and free if you only use 1 instance, but you have to renew or relaunch the instances every month.
     
  9. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Forge Networking Remastered Announcement!

    To all owners for Forge Networking. We are now taking requests to join the Forge Networking Remastered Alpha. Please send your requests in Slack.
     
  10. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    Hi,

    I have a need for an object to be on the server and on the generating client only. I had thought the following code would do it. But using the defaultmenu, the host gets created as expected, but when a client connects, nothing is created, no object on client, no corresponding object on server. So does this not work? or am I using it wrong? or is there a better way?

    Networking.Instantiate (objectToSpawn, NetworkReceivers.ServerAndOwner, PlayerSpawned);

    basically, I want any server created object on all the clients, but the client created object should only be on the server and that client.

    Something else I have found that's odd, just using one of the demos, I switch from udp to tcp, build and run a client, and run the server, pressing connect to ip on client does nothing. When udp it connects fine, when tcp, zippo, nada..

    Thanks
     
    Last edited: Jun 10, 2016
  11. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Add this line above it and post what it prints out
    Code (CSharp):
    1. Debug.Log("Networking instantiate test: " + ((Networking.PrimarySocket == null) ? "no primary socket " : " connection active: "+Networking.PrimarySocket.Connected));
    is this called from inside an SNMB that the client owns?
     
  12. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    Thanks for getting back to me.

    I already did something similar to what you suggest, so I'll include a screenshot which should show everything. Note: I am just using the Authoritive example supplied with Forge for this. So the only change is changing the NetworkReceivers. Its just not reacting like I thought it would.

    https://goo.gl/photos/7WntL95rrXLocXkV7
     
  13. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Hey, I still want to confirm the PrimarySocket is set, please drop that debug.log in :)
     
  14. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    Ah gotcha, I saw primarysocket and thought socket. Duh! I'll get you that tomorrow, don't have time today.
     
  15. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    65
    sorry about the mix up.

    Results are: Networking Instantiate test: connection active: True
     
  16. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    I've sent you a direct message to further resolve the issue :).
     
  17. MrGky93

    MrGky93

    Joined:
    Feb 27, 2014
    Posts:
    281
    is there now a tut how make it with mecanim synchron ??
    Because there is no tut how to synchron the mecanim video ??
    Better is make a small tut how to synchron the mecanim with the unity3d standart robot ??
     
  18. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    Here you go!
     
  19. Doompanther

    Doompanther

    Joined:
    Aug 11, 2012
    Posts:
    24
    Hey small problem: whenever I check the host.connectedPlayers, it doesn't register the host as a player. So my player count is always always off by 1. To spawn/create players I'm using the ForgeExample_MakePlayer system.
     
  20. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    The host simply isn't considered a connectedPlayer, just a structural choice for forge not a bug.
     
  21. Doompanther

    Doompanther

    Joined:
    Aug 11, 2012
    Posts:
    24
    Sorry about that, looking back that was probably a poorly worded or just stupid question. What I should do; with what I'm doing, is have a check to see if it is a dedicated server (a server where the host isn't a player). Something like If ServerStatus != dedicated, playerCount == host.connectedPlayers + 1. Else playerCount == host.connectedPlayers.

    And if it is a dedicated server just have it create a null player or something.
     
  22. Legend458

    Legend458

    Joined:
    Mar 13, 2016
    Posts:
    190
    Hi,

    This asset looks interesting, but I'm wondering can someone with minimal coding experience use this for large multiplayer games? How would the server database work? Also does the server do the calculations for the game mechanics(for example: a player hits a tree to get wood, does it show on the other persons screen)? Thanks!
     
    Last edited: Jun 19, 2016
  23. EDevJogos

    EDevJogos

    Joined:
    Jul 24, 2014
    Posts:
    75
    So, i'm very new in this whole multiplayer stuff, but i've noticed watching the vídeos and tutorials that they are all made trought localhost, does you guys provide a masterServer like unet or photon ?

    My plan is to make a game where all the calculations are made in the server only, and clients only recieve a update, like client press "w" i would send to the server this event, the server would calculate the new position of this client and return this new position value to him.

    I've done this with node.js and html5, but from what i saw until this point i can't figure out, if it's possible to do the same with forge and how to do it.
     
    Last edited: Jun 23, 2016
  24. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Hi Legend458,
    With minimal coding experience you will be able to utilise some of the networking features. But typically network programming will require at least a moderate level of programming.

    It would only be possible in a few scenarios to get very high player counts without much additional coding. And in regard to server side code and databases, we provide all of the functionality for servers and a full framework for authoritative and client hosted servers. But all of the actual logic for your game you have to code.

    should you want to get more coding practice you can certainly learn a lot from network programming and we highly recommend it
     
  25. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    There is a master server addon available, with it you can host the master server anyway you like. The MasterServer allows you to register server instances and then players can get a list of lobbies.
    http://developers.forgepowered.com/Tutorials#Master-Server


    What you describe there is authoritative input which is absolutely possible with forge and we provide a framework for doing so. So yes it is absolutely possible.
    http://developers.forgepowered.com/...iate/Working-With-Authoritative-Server-Option
     
  26. Legend458

    Legend458

    Joined:
    Mar 13, 2016
    Posts:
    190
    Hi and thanks for the reply!

    So if I have a fully functional single player game, do I just integrate it with Forge and will it work(like put the Forge menu in)? Also is there anyway to host dedicated servers instead of on a pc? Also does the server browser include player hosted games? I'm also thinking of having dedicated servers that have about 20-30 player spaces(I think this will decrease lag). Also will Forge be on sale anytime soon? Thanks once again!
     
    Last edited: Jun 23, 2016
  27. EDevJogos

    EDevJogos

    Joined:
    Jul 24, 2014
    Posts:
    75
    Exactly what i was looking for, thanks !
     
  28. ScarabDevs

    ScarabDevs

    Joined:
    Mar 12, 2016
    Posts:
    50
    How is an existing object networked properly? Say the server and client opens the same scene and in that scene is a GameObject with a script called Level. I want this script to control things about the level over the network but it also can't be instantiated because I need it to be in the level to begin with. I tried just making the Level script a networkedmonobehavior but that didn't work obviously.
     
  29. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Hi yes there is a way to host dedicated servers and player games can be registered to the server browser,
    You can find all the information needed in our tutorials. You may also want to lookup running unity in batchmode with command line args.
    https://docs.unity3d.com/Manual/CommandLineArguments.html

    and some resources like this console by the rust devs can also be helpful
    https://garry.tv/2014/04/23/unity-batchmode-console/
     
    Last edited: Jun 27, 2016
  30. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Be aware you can also use WriteCustom and WriteRaw, but it is perfectly plausible to instantiate a networked scene controller. Otherwise yes, typically you can start a scene with an SNMB inside the scene and it will work. You wouldn't want to use a NMB as it syncs position and rotation which isn't needed for a manager
     
  31. Legend458

    Legend458

    Joined:
    Mar 13, 2016
    Posts:
    190
    So with a singleplayer game, I just add the Forge menu and all the game mechanics will work without extra coding? Also is there any way I can host dedicated servers instead of on a pc? Thanks!
     
    TCROC likes this.
  32. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    230
    Forge Networking seems to be exactly what I've been looking for! However, I have a couple questions.

    1.) Does Forge Networking support multiplayer on the Xbox One and PlayStation 4? And if it doesn't currently, are there any plans to integrate multiplayer support for Xbox One and Playststion 4?

    2.) I am an experienced programmer in C# with a little experience with uNet (I made a very simple fps through a YouTube tutorial). Are there tutorials for beginners?

    3.) How is host migration handled when the host leaves the game? I did not like how in uNet the game just ended. I loved how it was seamless in PUN.

    4.) Is there any kind of release date set for Forge Cloud? Even just a rough target?
     
    Last edited: Jun 27, 2016
  33. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    No, Forge offers you a very solid framework to network your game. It won't be as simple as just adding the menu though. I'd really suggest you take a look at the tutorials and overviews linked (http://developers.forgepowered.com/Tutorials) to give you a feel for what you'd need to do.

    You'd need to think about which variables are being synchronized across the network and what methods need to be called at the same time for all players to make your game logic work.
     
  34. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    1 - Forge uses the standard socket protocols allowed by Unity, if Xbox and PS4 support these then it is supported on those platforms.

    2 - We have a huge library of tutorials here http://developers.forgepowered.com/Tutorials

    3 - It isn't natively supported, you could create this functionality by having clients connect to a second server at all times and programming some logic for all players reconnecting to a new host if the original host is lost. It would definitely require a bit of programming work from you to set up but the tools and framework is there.

    4 - We definitely are planning to support Forge Cloud, we don't have a date ready to give out at this time. Remastered which is in Alpha is specifically powered a Forge Cloud release.
     
    Last edited: Jun 27, 2016
  35. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    I apologize if this has been asked a million times before, but is there a basic FPS game asset that can be downloaded to start with? Since I have never done networking before, and not a lot of programming, it would sure be nice to start with something basic to understand how it's working and use it as the first building block. Thanks!
     
  36. Babars

    Babars

    Joined:
    Sep 16, 2015
    Posts:
    2
    Is it possible to use BRPC with interface?

    Code (CSharp):
    1.    void OnCollisionEnter(Collision col)
    2.     {
    3.         if (NetworkingManager.IsOnline)
    4.             return;
    5.  
    6.         IDamagable damagable = col.gameObject.GetComponent<IDamagable>();
    7.         if (damagable != null && canApplyDamage)
    8.             damagable.Damages(ballDamage);
    9.     }
     
  37. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
  38. King-Zee

    King-Zee

    Joined:
    Mar 5, 2015
    Posts:
    6
    Small bug report, there's a problem with overloading same RPC methods with different signatures, for example:

    Code (CSharp):
    1. [BRPC]
    2. void myFunc(int x, string a) { // do things }
    3.  
    4. [BRPC]
    5. void myFunc(int x) { // do other stuff }
    if I use an RPC call with the correct parameters like

    Code (CSharp):
    1. RPC("myFunc",NetworkReceivers.Everyone,m_Int);
    I'll get an error. The RPC call seems to always call the first declared method, no matter the arguments put in, thanks again.
     
  39. TCROC

    TCROC

    Joined:
    Aug 15, 2015
    Posts:
    230
    Is there a tutorial as to how to set up Forge Networking with cloud programs such as Azure? If not, is there a plan to make one anytime soon?
     
  40. foolish-frost

    foolish-frost

    Joined:
    Mar 18, 2009
    Posts:
    169
    Well. Just opened forge for the first time, and...

    The docs don't work?

    I grab and paste the following code:

    Code (CSharp):
    1. using UnityEngine
    2. using BeardedManStudios.Network;
    3. public class SendMyVarsMethods : NetworkedMonoBehavior
    4. {
    5. public int number = 53;
    6. private Vector3 direction = new Vector3(15.3f, 3.74f, 9.5f);
    7. protected override void Awake()
    8. {
    9.   base.Awake();
    10.   AddNetworkVariable(GetNum, SetNum);
    11.   AddNetworkVariable(GetDirection, SetDirection);
    12. }
    13. private int GetNum()
    14. {
    15.   return number;
    16. }
    17. private void SetNum(int newVal)
    18. {
    19.   number = newVal;
    20. }
    21. private Vector3 GetDirection()
    22. {
    23.   return direction;
    24. }
    25. private void SetDirection(Vector3 newDir)
    26. {
    27.   direction = newDir;
    28. }
    29. }
    And immediately hit errors on base.Awake(); not being contained in NetworkedMonoBehavior...

    Thoughts?
     
  41. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    I am very much a newb, but in a tutorial I was playing with last night I noticed the code below the video was diferent than the code in the video. I copied and pasted it and it worked. I think it's because of the newest update to Forge. I believe if you put it back like regular code it will work. Like this:

    Code (CSharp):
    1.  
    2. private void Awake()
    3. {
    4.   AddNetworkVariable(GetNum, SetNum);
    5.   AddNetworkVariable(GetDirection, SetDirection);
    6. }
    7.  
     
  42. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    OK, a friend of mine at work said he has a game controller that sticks and causes him problems. Well, I did have my old SideWinder Force Feedback connected to my machine. Went home at lunch to check, and yep, the joystick was laying in the same direction that my guy kept running. LOL. So, yeah, that's the kind of caliber guy you are dealing with here! :D In my defense, I had spent 3 hours at the DMV, dealt with a flat tire and just got off the phone dealing with a nasty soon to be X wife. So I let my frustration blind me. I spent 3 hours and reinstalled trying to figure out why my character kept running away.:)
    :(:p
     
  43. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
  44. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    The method is not invoked with RPC();
    You can easily write a second method and call RPC() on that second method from OnCollisionEnter
     
  45. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    We sometimes upgrade the code snippets to display a cleaner version of the code written in the tutorials. Feel free to message me with code from your project or post in our slack and I'll assist you directly.
     
  46. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Polymorphic rpc methods aren't supported at this time.
     
  47. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    We are intending on putting out an Amazon EC2 Linux hosting tutorial in July.
     
    TCROC likes this.
  48. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    You no longer need to override the Awake method while using forge.
    void Awake()
    {
    AddNetworkVariable(GetNum, SetNum);
    AddNetworkVariable(GetDirection, SetDirection);
    }
     
  49. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
  50. AlexVK79

    AlexVK79

    Joined:
    Mar 7, 2015
    Posts:
    2
    1. So unlike Photon Cloud we can host fully authorative (running all game logics) Forge servers ourselves, right?

    2. Do you have any benchmarks regarding sockets performance of the Forge server?
    I mean it's kind of cool that we get the server framework at $75 and have no CCU limit.
    But if a single amazon t2.micro can only handle 16-32 CCU the monthly payment per 500-100 CCU will become significant. So what is the approximate CCU limit (socket-wise) on a typical cloud instance (1Gb Ram 1CPU, etc)?
    Let's say we do something like Agar.io on Forge (super simple logic, can be well optimised so bottleneck is probably only in sockets engine) ? If your implementation is entirely C# it would probably be much less effective compared to Linux's epoll or Windows's IOCP, I guess, but how much less?
     
    Last edited: Jul 1, 2016