Search Unity

[NO CCU LIMIT] Forge Networking now OPEN SOURCE

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

  1. maglat

    maglat

    Joined:
    Jul 9, 2010
    Posts:
    111
    This tutorial is about setting up a relay server, right? Do this work with Websockets?
     
  2. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    310
    Madness Sale is now live! This is going to be your chance to get Forge Networking + Forge Networking Remastered (Free upgrade when it comes out). Have fun Networking and thank you all so much for your support!
     
  3. g-hoot

    g-hoot

    Joined:
    Apr 18, 2015
    Posts:
    69
    1 of 5,133

    Can Forge Networking be used for LAN where the players log into the server using the servers IP?

    Hello,
    I’m a rookie at C# and Unity programming, so this may be way beyond me, but I would like to try to create a simple multiplayer game for me and my buddies at work. We can’t get through the firewall, so only LAN games are possible (we currently play BF2). Does Forge Networking support LAN in this way where we connect to the servers IP?\
     
  4. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    So the player can still instantiate like normal, there is an authoritative example that ships with forge, this includes showing you a player being instantiated.

    The server gets authority if the "Server is Authority" setting is enabled, otherwise the player gets authority. The person who spawned the object gets ownership, ownership of an object can be changed by the server or the owner of the object.

    The concept of ownership and authority in forge is pretty typical for network programming design,
    Ownership - this simply says which player (or it can be the server) owns the object and can write to the other players (so if player A owns object A, player B cannot write to the network from object A via any of the featured forge ways of sending stuff across the network like a NetSync variable).
    Authority - this isn't relevant between players at all, it directly refers to whether the position/rotation of the object can be set by the player or if ONLY the server can set the position/rotation. If the server is authoritative, you use the authoritative input system to influence the position.

    Think of server authoritative systems like this (and it explains why MMOs are quite hard to 'hack'), in a normal game you might be sending your player position to other players all the time. This runs the risk of a player simply sending wild positions to the other players flying, underground or maybe just teleporting. So instead of letting the players simply send their position authoritative input has you simply send the key you press to the server and all of the gameplay happens on the server. The server then sends the position to all the players, much safer and much more secure.

    This is a simple setting for interpolation, interpolation will continually move an object closer and closer (or rotate closer and closer to the angle). The problem is, once the position or angle gets close to the desired pos/rot it continues to move in smaller and smaller increments. Rather than pointlessly moving or rotating in tiny increments you have a 'stop distance/angle', once it reaches this amount it simply stops interpolating to save performance.

    You can disable if you don't need any of the settings to be synced across the network, otherwise you can specify which if any should be synced and if they should simply be synced across the network or smoothly interpolated to the value being sent across the network.

    It simply lets you designate a single object for each connected client, as their 'player'. You then have a few easy methods for finding that single object rather than having to loop through all their 'owned' objects.

    This is exactly what authoritativeTeleportSyncDistance does at the bottom of NMB, used in combination with client prediction this will also simulate the authoritative input locally :)

    Client side prediction essentially executes the input methods locally as well as on the server, you then use authoritativeTeleportSyncDistance to ensure they never slip too far apart.

    You can reasonably easily create a variable that reads the axis of the gamepad, Sync the value with the server likely with a NetSync. Then somewhere in the server have an Update execute an if(isServer) block of code. Potentially you could execute it on the client as well to get the client side prediction.

    (I'll be adding an AuthoritativeInputAxis this month if that sounds like too much effort)

    Literally just saves you from checking ownership (and we might be trying to enable better looking code to be written).

    Cheers and thanks for the interest,
    - Mark and the Forge Team
     
  5. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Correct and yes websockets can communicate with the normal server system (as websockets cannot host servers i.e in the browser)
     
  6. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Yes, you simply use the LAN ip to connect and voila (a lan ip looks typically like 127.0.0.1 as opposed to your usual ip)

    Forge also support NAT punchthrough, this is essentially how you are managing to connect to servers despite your firewall restrictions in AAA games like BF2.
     
    g-hoot likes this.
  7. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
  8. motion-art-game

    motion-art-game

    Joined:
    Dec 17, 2015
    Posts:
    24
    Really loved the solution you are providing.I am mobile LAN game lover.
    I have done several experiments on UNET and able to run game in LAN mode where server discovery is possible for client device. My game works perfect if all play through router.

    My code stop working when user wish to play the game in WIFI hotspot mode.One of the friends start WIFI hotspot and other friends join it.Then any one can create game server and all client (friends) can join the server.

    Will forge networking be helpful in my case?
     
  9. ScarabDevs

    ScarabDevs

    Joined:
    Mar 12, 2016
    Posts:
    50
    @FisherM Thanks for that lengthy reply! That cleared up most of it for me. I managed to get instant input on clients while the server is authoritive! My problem now is rubber banding, I know that AuthoritativeSyncDistance and AuthoritativeTeleportSyncDistance are meant to help with this but in my case they seem to do absolutely nothing. I tried giving them crazy low and high values just to see if it changed anything and it doesn't look like it. I'm using the free version V16.9, is this a bug that is solved in the latest build or am I doing something else wrong?

    Players join a sort of lobby where they select characters and when the host begins the match, it loads a level on the server and all clients. When I do this, I always get this error :
    Code (CSharp):
    1. NetworkException: Network variables can not be added after the Awake method of this MonoBehaviour
    What's causing this and how do I fix it?
     
  10. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    Just bought this. I like it. The ability to switch Ownership on the fly is a huge feature for me.

    The question I have has to do with the built in interpolation. Is this used on variables that you would declare and control via "AddNetworkVariable"? I have a special use case that I want movement and rotation interpolation but I also want the ability to control if a client will actually listen to the server/owner about its position. I can do that in the getters and setters but I am concerned that I will now have to write my own version of the interpolation code (I could probably do this as well but I would rather use the code you used for it).

    This looks like a great product so far. I am a little concerned that Remastered will mean that everything I am learning and writing now will be obsolete in a month or two.
     
  11. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    same as anything else you want to setup a NetworkedMonoBehavior or SimpleNetworkedMonoBehavior depending if you want the Transform position and rotation auto-synced. Otherwise you may want to create a new class for your need and inherit from SNMB.

    Checkout our tutorials, it's a great place to get all of this information
    http://developers.forgepowered.com/Tutorials
     
  12. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Try setting the AuthoritativeSyncDistance high and the AuthoritativeTeleportSync Distance low, if the server version of the character isn't moving it may cause your issue. Make sure your movement system is actually moving the server version of the character.

    I'd need to see the class where the networking variable is setup

    You can check our tutorials for usage examples of NetSync variables also
    http://developers.forgepowered.com/Tutorials
     
  13. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Hotspot wifi should work exactly the same as normal lan :)
     
  14. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Create a property, add the NetSync attribute, inherit from NetworkedMonoBehavior and then finally make sure the NetworkedMonoBehavior has interpolation enabled.
    You can simply write into your property the getter and setter to set and retrieve the data as needed.
     
  15. ScarabDevs

    ScarabDevs

    Joined:
    Mar 12, 2016
    Posts:
    50
    PawnSettings.jpg

    I tried setting the sync settings as you suggested, it didn't help, went back to these settings as I think maybe it's slightly better... Not really sure if anything changed though.

    I'm sending d-pad input to the server and the server adds velocity appropriately, at the same time I add that same velocity to the client. If I select the player on the server in the editor and directly move him around, the client updates to the correct position. So it all seems to be working, except that it's pretty twitchy to say the least.

    Can you elaborate on the sync distance and teleport sync distance? Does sync distance mean at what distance from the true position should it start try to interpolate to the correct position and any distance below that it won't touch the position at all? And teleport sync distance repositions the character if it gets further from the correct position than teleport sync distance? Again, I have tried many variations of those 2 values with little difference if no difference at all.

    Also, I'd still love to know about this error that occurs when I network load a level ;)
    Code (CSharp):
    1. NetworkException: Network variables can not be added after the Awake method of this MonoBehaviour
     
    Last edited: Jun 5, 2016
  16. zhuchun

    zhuchun

    Joined:
    Aug 11, 2012
    Posts:
    433
    Hi, I'd like to know some details before purchase it :)
    1. What kind of network it supports? Wifi LAN or Internet?
    2. Does it support lobby server? Say put a nodeJS for clients so they can connect others easily.
    3. Does it support generic type data?
     
  17. motion-art-game

    motion-art-game

    Joined:
    Dec 17, 2015
    Posts:
    24
    As you have already mentioned that it can be played in Mobile HOT SPOT LAN then only last query remains before buying.
    Will I be able to put server discovery mode where user can search server in LAN mode? I do not like system where user need to type IP manually.
     
  18. Frillgame

    Frillgame

    Joined:
    May 26, 2016
    Posts:
    5
    How does this networking asset handle multiplayer survival games like rust and h1z1? with 200-300 players and a build system?


    I am going to start a game like that and looking for a networking system to build it around.
     
  19. Enoch

    Enoch

    Joined:
    Mar 19, 2013
    Posts:
    198
    Thank you for the help. Now I have even more questions:

    1)Is this a great place to ask technical questions or is there a more appropriate place?
    2) I am trying to send a request to the server to give a certian client ownership on a specific list of objects. I first attempted to do this with an RPC however I need to send a variable list of NetworkedIds to specify which objects the client wants ownership of. Apperently Lists don't serialize. Whats the best way for me to do this? I want to send a ownership request with a list of NetworkedIds and receive (only on the client that sent the request) a list of NetworkedIds the client now have ownership of.

    I really did look through the documentation but there doesn't appear to be a way to custom serialize the argument parameters of an RPC call. Is there a way to send an array of bytes as an argument to an RPC? I don't mind serializing it myself though I would prefer an easier way.

    Thanks for the help.

    Edit: As for #2 when I looked at ObjectMapper in the code I saw that you supported byte[] so I solved my issue using that. After looking at the code I may just straight up add to the object mapper to support my project specific classes. Perhaps as a future upgrade you would consider allowing a third party a position in this method to call our own external mapping controls should the type not be found. That way I could have a place to put my project specific mapping without breaking the upgrade path. I'd also suggest a switch instead of a chained if, but I think modern compilers do that for you anyway.
     
    Last edited: May 27, 2016
  20. motion-art-game

    motion-art-game

    Joined:
    Dec 17, 2015
    Posts:
    24
    Hotspot does not work exactly in game because the device which decided to become hot spot can not see other device.
    UDP multicast stop and I was not able to figure out the solution because I am not hardcore networking developer.
    That is why I am willing to buy your asset.

    As you have already mentioned that it can be played in Mobile HOT SPOT LAN then only last query remains before buying.
    Will I be able to put server discovery mode where user can search server in LAN mode? I do not like system where user need to type IP manually.
     
  21. Doompanther

    Doompanther

    Joined:
    Aug 11, 2012
    Posts:
    24
    Will these be updated with the Remastered version? Because a few of them are already out of date with the current version.
     
  22. Doompanther

    Doompanther

    Joined:
    Aug 11, 2012
    Posts:
    24
    I'm new to Forge so my knowledge is limited.

    1. I've been able to connect to a host on a LAN and over the internet. So both.
    2. Yes, there is a Master server tutorial on their website that shows you how to do this. Here: http://developers.forgepowered.com/Tutorials#Master-Server
    3. What do you mean? Like int's and floats? If so, yeah you can serialize those over a network: http://developers.forgepowered.com/Tutorials/GettingStarted/Custom-Networked-MonoBehavior
    I'm sure there are other ways to do that but I haven't gotten that far yet :p
     
    zhuchun likes this.
  23. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Hi there i am thinking about buying this system but it brings me 3 questions.

    1: Is it possible to make a lobby system within it?
    2: Should this be a good system for making a multiplayer fps?
    3: Should it work with UFPS?
     
  24. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    1. Yes. It is just the networking part though. You will need to write the lobby system yourself.
    2. Yes. It is just the networking part though. You will need to write the multiplayer code yourself.
    3. Yes. It is just the networking part though. You will need to write the integration with UFPS.
     
  25. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    I don't get de second question as i look to the video he only adds a network view and the characters are multiplayer?
    is this also with animations? and is it for a beginner like me learnfull and easy to learn?
     
  26. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    What video are you referencing?
    Networking (in general, not just Forge) doesn't "do" animations. You need to write an RPC or something.

    I would say that you need to learn networking in general. It doesn't matter what you use. Forge is good as any and pretty easy to use. But if you are expecting Forge Networking to automate UFPS, with lobbies and multiplayer integration, in the way that UFPS is a game *system*, you're sadly mistaken. It is only the lowest piece of the puzzle. The foundation. You still need to build the whole house yourself.
     
  27. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Well i made quite a fre projects i made a agar.io clone with socket.io an c# but i am totally new to this kind of networking and i already made a lobby system with photon but still. I want to learn more and more and i am just wondering if this is a good faundation before i buy it.
     
  28. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    If you are looking for a good networking package, yes, Forge is a good networking package. I bought Forge, and I would buy it again.

    However, having said that, why buy Forge? Why buy anything, if you are learning? If you are learning, then use UNET. It is free and will teach you about "multiplayer networking" in general. Then, once you better understand the concepts, you can look at getting something like Forge.

    Whichever way you go, good luck. It is always fun learning new stuff, at least for me. If you do get Forge, make sure to join the slack channel for help.
     
  29. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    What is slack ? and what is the channel then i will join surely i will buy forge and try it either way because its in sale XD
    And i made my own gamemode for UFPS multiplayer add-on so i know the basics of RPC UNET etc.
     
  30. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    See this post re: slack

    Have Fun!
     
  31. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Thanks i'm going to buy it right now!
     
  32. motion-art-game

    motion-art-game

    Joined:
    Dec 17, 2015
    Posts:
    24
    Is there a chance that I reply for my query.
    I am waiting from last 16 hours.
     
  33. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Okay i joined slack it would be nice if there was some kind of a chat :O
     
  34. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    Slack IS chat. Just start chatting on the appropriate channel.
     
  35. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Sorry i quess i am freaky blind i don't see any chat.
    and Apps slides in a blank sidebar,
     
  36. Tinjaw

    Tinjaw

    Joined:
    Jan 9, 2014
    Posts:
    518
    Are you on https://forgenetworking.slack.com/messages/general/ ? Or are you on the developer website?

    Once you register you need to get an invite from the developers to get on Slack. If you registered, email them asking for an invite.
     
  37. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Haha i was in the developer site i quess :D
    Well then i have to wait untill i get a invite
     
  38. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    try setting the throttle a little hight, 100 ticks is very high.
    but most importantly set Distance to something like 5~10 and teleport 3~4
    As the messages says, add the network variable pre awake()

    Code (CSharp):
    1. void Awake(){
    2. addVariable();
    3. base.Awake();
    4. }
     
  39. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    I am following this video:


    And this is the error i got -_-?
     
  40. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Hihi following the tutorial doesn't work look my previous post XD
     
  41. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Announcements!
    We have uploaded 2 videos today about progress on Forge Networking Remastered (free to everyone who owns and purchases Forge Networking). Our hope is to move into an Alpha build next week to get early adopters testing out the system :). Please provide us with any feedback, and we are NOW taking requests to join the closed alpha just testing mentioned. Please us a message on Slack with the request as we have a private channel there for the group! :)



     
    CarterG81 likes this.
  42. DshFox

    DshFox

    Joined:
    Oct 10, 2013
    Posts:
    15
    looks gorgerous! I read the sub reddit forum and it's very cool. Could you talk more about nat punch, matchmaker and things like that? Also, just to confirm, if I buy forge network in madness sale, will I recieve the new forge remastered? Will it be the same link from asset store(upgrade) or it will be a different link at asset store? Thanks bro ;)
     
  43. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Thanks! We are hard at work on the remastered version :)

    NAT Hole Punch has been tested internally, basically it is a server that can be hosted that game servers can register with and clients can be "routed" through. We will be providing a demo video for this over the next week as well to explain it further :). As for matchmaking, it is in its early stages and we do not want to establish any expectations with it at the moment. We will be going further into details on these topics as they are further developed :).

    You will get Forge Networking Remastered if you purchase during the madness sale :)

    We will be uploading to the same asset store link :)
     
  44. smokegun

    smokegun

    Joined:
    Dec 13, 2012
    Posts:
    170
    Okay i just bought it a few hours ago and together with a video of the creatures i made a standard multiplayer third person i quess. base.Start(); isn't needed anymore and that protection override isn't needed anymore.

    I managed to get it working and that everyone has he's own player and camera with smart thinking and customizing the script/prefab.

    I am inlove with this insane awesome system!
     
  45. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Yes, the override methods were deprecated in version 15 :) That one was well received

    Awesome! :D Thanks we are constantly working hard to make this system the best available :)
     
  46. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    Yes, forge can definitely make a game like rust or h1z1. Having 200-300 players is definitely more a challenge for how you design the server and netcode, but again is very definitely possible.
     
  47. FisherM

    FisherM

    Joined:
    Dec 28, 2013
    Posts:
    366
    1) Slack chat is the best place to ask questions and get quick responses once you own the product.
    2) Two points to this, first you can always convert a list to an array with .ToArray(). However you can look into C# serialization and serialize data to a byte[]. Which is the typical way to transfer data. Byte[] can be sent as normal.
     
  48. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    While I haven't done anything more than 4-8 players at once, I have successfully "networked" a huge open world with tens of thousands of objects, on an authoritative server. After Forge Remastered is released and I upgrade to it & then find the time, I'm going to try to write a tutorial or an asset about how to do it. But if you have any questions, I could give you the gist of it. However, I haven't done anything with the players or npc's, since that works out of the box for a few players. You might have to handle the players/npcs in a different way to achieve hundreds of them, idk. Plus you might want to have some cheat detection/prevention code added (I didn't do any of that, but the structure is there if I wanted to add any).

    But the general idea of how to design that authoritative part is pretty simple with Forge. Syncing a huge world & all those interactable objects (trees, items, rocks) isn't easy by any means, but it's simple enough once you figure out how to design it.

    I also have more than just it networked, like a save/load to file system for the server to effortlessly save the game state, etc. Since everything needs to be serialized to send across the network anyway, and the server has to send the entire world anyway (a single custom serialized class), the same system can save/load the entire world to file effortlessly.

    I thought of maybe turning everything I've got so far into a paid asset, like an "Open World Sandbox Game Starter Kit" with wrappers, where the user links their networking package & "it just works". (Maybe later supporting UNET & other packages besides Forge, if it sells well). However, that seems like a lot more work than just a simple tutorial. Either way, I need to wait for Forge Remastered to make sure it works. That way I'm not writing an old tutorial/asset.

    But it was difficult enough for me to figure out, that I really want to share how others can easily do the same thing. Take my weeks of work & turn it into a few hours for them (easy to follow tutorial).
     
    Tiny-Tree and impactit like this.
  49. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
  50. motion-art-game

    motion-art-game

    Joined:
    Dec 17, 2015
    Posts:
    24
    sorry to re post but I did not ge answer for my query.

    Will I be able to put server discovery mode where user can search server in LAN mode? I do not like system where user need to type IP manually.