Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[NO CCU LIMIT] Forge Networking now OPEN SOURCE

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

  1. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Yes, we have removed a lot of code that was around since beta that was needless bloat or has been upgraded to other parts of the library.

    @b889965 is right, you will need to delete the Bearded Man Studios, Inc. folder and then import. We tried to make it so that the older files would blank out in the new version :( Unfortunately it seems to not have taken effect during the Unity import process
     
  2. GlobalHive

    GlobalHive

    Joined:
    Jan 13, 2014
    Posts:
    18
    Nah didnt testet it... but i deleted it now and reimported everything and its working again :D

    Well thanks :D Maybe write it down on the Profile page else you will have much requests on this small pointless thing :D
     
  3. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    I agree, I am sorry about this, I have added it to the original post but I'll add it to the profile page and the wiki
     
  4. GlobalHive

    GlobalHive

    Joined:
    Jan 13, 2014
    Posts:
    18
    No problem you are just an Human like me :) Or not o_O

    Last question for this week...
    I dont get it how i can determine which "cube" belongs to which player

    Like i want to send an private message so i need the ID / Name or something so not everyone will be able to read it

    But how ?
     
  5. hyiero

    hyiero

    Joined:
    Jun 12, 2015
    Posts:
    7
    Are the forge forums broken atm?
     
  6. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello, currently I am not with any of my computers to give a full reply. I have checked the forums on my phone and they seem to be working fine. Did you purchase forge through the Asset Store? If so, did you register your invoice on the profile page? Also we had some issues with the verification email yesterday so you may need to send us an email if that is the case. :)

    Thank you for letting us know, here is the forum URL I checked on my phone: http://forums.forgepowered.com/
     
  7. Techips

    Techips

    Joined:
    Jun 9, 2013
    Posts:
    238
    Works fine for me
     
  8. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    XD I would hope that I am human (still).

    Well the server really tracks all of the players and the players do not track each other (though you can call the PollPlayers RPC that is in the NetworkingManager). Once you do this, then the player list can be found on a client via the NetworkingManager.Instance.Players. :)

    You can actually set the name for the player objects. In the demo if you press "B" you will see that your cubes name will change to "Brent" across the network. If you press "F" you will see that then name will then be changed to "Farris" across the network. Feel free to modify these functions so that you make sure that the names are unique. You can probably take advantage of the Cache system for this as well :). The server will know each of the cubes player id's so it can make the association.

    Please let me know if this helps :)
     
  9. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hello! Why thank you :)

    We take advantage of the built in physics system in Unity so you should be able to program your game as you normally would in that respect :)

    Technically yes, it would spin up a new server to support this. There are various things that you could do in order to work with this. You can make one of the clients be the host, however if you are looking for security and tracking the player data securely, you will want a way to make sure that there is no cheating going on and probably opt to host all of the servers yourself.

    The server scales appropriately to larger user sets as you can specify the different sizes of the servers if you wish. The CPU usage we have been told by those who come from SmartFox is comparable and lower in many cases. We did our best to optimize the system everywhere we can so that it uses algorithmic lookups rather than scanning through arrays or lists.

    Currently we do not have the concept of Peer-2-Peer as every message is relayed through the server for security as this is the industry standard (authoritative server). Peer-2-Peer is extremely insecure in many ways and is a huge headache to try to secure it. However you can make a game seem peer-2-peer by having your players have the ability to host servers if that is what you are asking :)
     
  10. shwick

    shwick

    Joined:
    Jul 10, 2015
    Posts:
    31
    Thank you for the in depth reply. I'll be experimenting with both models to see which works best for me.

    edit: the peer-2-peer question was just because that australian company tried to do it. I think they researched it for years and then recently just shut down. They tried to offload stuff I dunno was just theoretical haha.
     
    Last edited: Jul 19, 2015
  11. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    Lot of exciting news coming up everyone! Please hop on the Forge bandwagon while you can! :)
     
  12. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    Goodness, 2 weeks after purchasing Forge...I'm finally able to start using it! I've been so busy I hadn't yet had a chance.

    I am going to try to document my transition from a broken UNET, to a working Forge.

    I was really excited seeing a post about tutorials to go from UNET to Forge. I must have misunderstood, because I thought they already existed and we were encouraged to add more to it.

    No problem though! Since I really wanted a transition tutorial (just to play it safe) and saw there wasn't one yet and instead that was you making it easier for US to document our transition (which I absolutely love. Thank you!)- it was clear that without a doubt I should be documenting this for other people. Especially for those that don't have the experience to do this stuff easily themselves.

    A year or two ago, I was among many others who had a frustrating experience with learning this stuff. I really don't want to take my newfound experience for granted by pretending "It's so easy!" or being another one of those internet jerks "If you can't do this, since it's easy, you will fail at gamedev!" Instead, I want to help people learn and give them those tiny bits of information that can sometimes take hours to realize- but if someone just told you, would have only taken minutes.

    After all, it's the least I can do to give back to an Internet that has given me so much knowledge, and a developer (BeardedManStudios) that is putting so much effort into great documentation AND giving us the tools to assist in making it even better.

    Anyway, I've started a UNET to FORGE transition tutorial HERE.

    If anyone notices I'm missing any step, please edit it or inform me. I had to backtrack a little bit and add UNET back into my project the best I could since I had already done a few steps to replace it with Forge. So it may not be perfect. I am also doing this as I go along, so it may not be the best either. However, once I'm finished I will try to find the time to polish it up a bit. All suggestions/criticisms for improvement are welcome, as I am not an experienced tutorial author. All I care about is that this is a good tutorial for others to use.

    The tutorial is a [WIP]. I wanted to submit it as I write it out, so I can have the correct formatting as I write it. I don't know if I will be able to finish it today or not. I will however get it done soon since I am finally able to return to gamedev as my "full, part time job", thank God :D
     
    Last edited: Jul 21, 2015
    Cranick, Brent_Farris and DMeville like this.
  13. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    Awesome, I have updated it a bit and am excited to see how it turns out!

    Thank you so much for your support! :)
     
    CarterG81 likes this.
  14. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    Wow, thanks for the fixes. My grammar is a lot worse than I thought, hehe :p
     
    Cranick likes this.
  15. taz_ack

    taz_ack

    Joined:
    Jun 13, 2015
    Posts:
    3
    Hi,

    Is there a way to test Forge before buying ? I don't see a free/limited/demo version on the store.

    thank
    Tazack.
     
  16. ZhavShaw

    ZhavShaw

    Joined:
    Aug 12, 2013
    Posts:
    134
    I hope you haven't forgot about the public kit (logos, etc.)
     
  17. TrentSterling

    TrentSterling

    Joined:
    Jan 4, 2013
    Posts:
    80
    Buying this tonight. Hopefully the NAT punchthrough will be here soon.

    EDIT: I verified my email and added my invoice to my profile. Is the wiki account created automatically? If so, it didn't work :(
     
    Last edited: Jul 21, 2015
  18. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Hi there, yes, if you verify your email and add in your invoice number then you should have access to the wiki. Did you log in with the same username/password that you use for the site?
     
  19. TrentSterling

    TrentSterling

    Joined:
    Jan 4, 2013
    Posts:
    80
    Yes, same username and password. Login works on the forums and the developer area, but not the wiki. I've been locked out of logging in for too many failed attempts. It tells me to wait 5 minutes before trying again, but I've waited an hour+ and still nothing.

    EDIT: Tried from another machine, got this:
    Says the account doesn't exist, but it's the same username Im using on the dev portal/forums
     
  20. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Strange, others have not had this issue. I had a few users and test accounts work just fine after reading your post. I will turn off the lockout for your account so that we can test to find out where the bug is. If you would like, please send us an email to support@beardedmangames.com so that we can get this resolved for you.

    Has anyone else had this issue where they can not login to the wiki after purchasing from the website or registering their asset store invoice on the site?
     
  21. TrentSterling

    TrentSterling

    Joined:
    Jan 4, 2013
    Posts:
    80
    Sent an email. I wonder if it might have something to do with the order in which things happened when setting up my account. The verification email was taking a while, so I added my invoice to the account before my email verification link had come through. Maybe doing things in that weird order messed something up?
     
  22. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    I think I may have figured it out! Looks like mediawiki will replace "_" characters with a space, causing your username to be incorrect when we look it up with our custom login code. I have made changes to support spaces and underscores in the mediawiki login. I am very sorry about this! Thank you so much for helping us find this bug :)

    Please let me know if you are able to login now.
     
  23. TrentSterling

    TrentSterling

    Joined:
    Jan 4, 2013
    Posts:
    80
    That was it! I'm able to log in on an alternative IP but I'm still locked out on my home connection.

    EDIT: Renewed my IP so I could get in.
     
    Last edited: Jul 22, 2015
  24. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Awesome :) Sorry about the trouble.
     
  25. Techips

    Techips

    Joined:
    Jun 9, 2013
    Posts:
    238
    We want to know what it up!!
     
    CarterG81 likes this.
  26. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    Currently there is not a demo/free/limited version available. We have have stopped beta a couple months ago and have been polishing our release of Forge. We do have plans in the future to have a trial version of this but it is further down our current internal roadmap.

    If you have any questions about our networking solution please feel free to contact us at support@beardedmangames.com and we would be more than happy to assist you on any further information you might need to know.
     
  27. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    We have not forgotten! Thank you for being interested in it and we should have it soon. :)
     
  28. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Version 10.9 Released

    Hello everyone! This update had some critical fixes that were reported mainly from our users who found bugs with their interesting looking projects. :) I am sure many of you have been flustered with the incorrect IP address join crash we had due to our run-away connect thread; we have fixed this please feel free to report any other crashes!
    • Fixed issues with the connect event on start scene
    • Fixed common unity editor crash issues
    • Fixed reliable packets sending large packet count desync
    • Fixed reliable packets being sent too slow after desync fix
    • Fix issue with received reliable confirmation being out of sync

    Thank you all so very much for your amazing feedback and bug reports! Please feel free to leave us a review on the asset store if you haven't already :D
     
  29. Manimor

    Manimor

    Joined:
    Sep 7, 2013
    Posts:
    21
    I'm officially a forger :), but the activation mail hasn't come yet :/ and I cant see if I typed it correctly, is there nowhere to change mail? Looking forward to see what can be done with this :)

    edit: nvm it arrived :p
    edit2: This authorative stand alone addon, is it bare metal?
     
    Last edited: Jul 22, 2015
  30. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    Awesome! Thank you so much for the support and welcome to the community!

    Oh good, I just hopped online to make sure I helped you with this, glad to see that it finally came :)

    Yes, Bare Metal will be the Non Unity Instance server. It's official release will be very soon :). As for now, you are able to build your unity instances in Windows and use the "-batchmode" flag or as a Linux Headless build :)
     
  31. psistalk

    psistalk

    Joined:
    Sep 23, 2013
    Posts:
    56
    I have been using forge for a few days now. It is exactly what I have been looking for. Videos are perfect and took little time to get my game working. I'm working on setting up multiple zones and looking forward to the future of Forge.
     
    Cranick and Brent_Farris like this.
  32. jlcra

    jlcra

    Joined:
    Jan 27, 2014
    Posts:
    13
    Hello - We have been trying to get generic TCP socket communication working in Unity but are having some trouble. Is Forge a potential solution for us?

    We basically have a 3rd party server (written in C++) sending out data over a TCP socket that we want to connect and listen to, and send data back to it. Can we use Forge to do this easily, or is it mainly designed for pure Unity to Unity multiplayer communication?
     
  33. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    The TCP sockets that we have is designed around our system protocol. It would be able to support raw communication in the future but right now isn't able to do so.
     
  34. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    Awesome! I'm looking forward to seeing how your game turns out! Please feel free to reach out to us if you have any questions/issues/suggestions. :)
     
  35. hMark

    hMark

    Joined:
    Oct 16, 2013
    Posts:
    15
    Hello, it is possible to download and use 10.9 version? In asset store is still 10.5.

    Also, we ran into issue with [NetSync("Callback", NetworkCallers.Others)] variable which is changed only by server. Initial change with sync from server is OK but after that there are random empty string syncs executed on the client without server call.

    Thanks!
     
    Last edited: Jul 23, 2015
  36. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    You can download the latest from http://developers.forgepowered.com/Profile (If you haven't registered yet, you can do so there and be able to always get the latest version whenever it is available from there). Just register your transaction # from unity to your account and you should be set. Contact us via support@beardedmangames.com if you have any problems and I will be able to assist you.
     
  37. roychr

    roychr

    Joined:
    Jun 16, 2009
    Posts:
    33
    Hi, I have a simple question, does your cloud service enables developper to start a new instance of a game as to shard zones ?
     
  38. b889965

    b889965

    Joined:
    Oct 10, 2014
    Posts:
    8
  39. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    I'm almost done with converting my project from UNET to FORGE. It's taking a lot longer than I thought it would.

    Although I might be working a lot slower than normal, I can't tell since I'm so new to networking. (Perhaps the tutorial writing is slowing me down a ton? No idea. It could just be headaches or distractions, as I don't feel I'm fully back to work normally.)

    Anyway, I still need to finish a few things and double check that everything works as it should. So far, it seems to be working great.

    I had a few questions though, mainly for clarification. Forgive me if some are simply things I should have looked at in the documentation. I'm having trouble focusing right now and am retiring for the day.


    1. Is there anywhere in the documentation that explains why the "Buffered Network Instantiate" tutorial uses the following code?

      Code (csharp):
      1.  
      2. if (Networking.PrimarySocket.Connected)
      3. //
      4. else
      5. {
      6. Networking.PrimarySocket.connected += delegate()
      7. {
      8. //
      9. };
      10. }
      11.  
      I am a novice programmer, so I don't entirely understand the whole "+= delegate()", and I didn't hear in either tutorial (Network Instantiate or Buffered Network Instantiate) where PrimarySocket.Connected came from.

      The tutorials go from just using the Networking.Instantiate() method, and then suddenly adding all this extra stuff. There's a lot of tutorials, so maybe I'm just missing the link?

    2. For structuring our playerPrefab, should we confine all networking logic to a single NetworkedMonoBehavior script? Should we only ever have ONE NetworkedMonoBehavior for each gameobject? This seems to work similar to UNET's NetworkIdentity (where you only need/want one, and it holds a lot of the network information. UNET's NetworkIdentity is the core of every gameobject's networking). I ask this because in UNET I had a lot of networking scripts, but replacing UNET with Forge, I see a lot of the huge green buttons, lerping sliders, etc. because I have multiple scripts on my player gameobject that use networking methods. Mainly [NetSync] variables or Network Instantiation.
    3. Is there anywhere that explains the "Resources Directory" for the NetworkingManager? This seems like an awesome feature.
    4. Is "isPlayer" just checking if it's a Client? I got a little confused when one tutorial began talking about the Player & Player Count, when all I see in StartGame.cs is starting a "Client" not a "Player". UNET makes a big deal about a single "PlayerPrefab", but from the tutorials so far I see there is no such thing and we just instantiate playerprefab gameobjects via something like the "Buffered Network Instantiate" tutorial?
    5. In UNET, you create a gameobject first (including setting its position and all its data) and at the END of creating/modifying it, you call NetworkServer.Spawn(). It knows which registered spawnable prefab to create and then what to modify with it. I noticed that we can call Networking.Instantiate(GameObject, NetworkReceiver) instead of the tutorial's Networking.Instantiate(string, NetworkReceiver). Is this similar to UNET? I have a few more steps I have to do before I can test this. I'm just trying to spawn gameobjects at specific positions or changing a few variables. (Trying not to change my UNET code too much when converting to Forge, since that's the goal of the tutorial).

    All of this can basically be found in my tutorial. I've left things either [WIP] where I haven't gotten to them yet, or [???] with a question or needed clarification.

    I also don't know if the tutorial is any good. I am worried that I am making it needlessly complex/confusing. Writing a technical tutorial isn't as easy as other tutorials. I also don't know how to upload images, which would help a lot (to show, rather than to type).

    Thank you!
     
    Last edited: Jul 25, 2015
  40. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    I had a lot of scripts with just [NetSync] variables, like my PlayerCharacterStats script.

    Code (csharp):
    1.  
    2. public class PlayerCharacterStats : MonoBehaviour
    3. {
    4.    public int MaxHealth = 100;
    5.    public int MaxHunger = 100;
    6.    public int MaxThirst = 100;
    7.  
    8.   //Used to be [NetSync]
    9.    public int CurrentHealth = 100;
    10.    public int CurrentHunger = 100;
    11.    public int CurrentThirst = 100;
    12.    public int MoveSpeed = 400;
    13.  
    I didn't want multiple NetworkedMonoBehavior scripts, so I just made one called "PlayerNetworkScript" which holds all the [NetSync] variables, which are always equal to these other scripts via Update().

    Another script holds all my RPC calls (so far only for the Player) called "MultiplayerCommands" and is just a SimpleNetworkedMonoBehavior.

    Is this bad practice? It was the simplest way I could think to do it.

    Code (csharp):
    1.  
    2. public class PlayerNetworkingScript : NetworkedMonoBehavior
    3. { //PlayerCharacterStats.cs
    4.   PlayerCharacterStats myPlayerCharacterStatsScript;
    5.   [NetSync] public int CurrentHealth = 100;
    6.   [NetSync] public int CurrentHunger = 100;
    7.   [NetSync] public int CurrentThirst = 100;
    8.   [NetSync] public int MoveSpeed = 400;
    9.  
    10.   protected override void Awake()
    11.   {
    12.       base.Awake();
    13.       myPlayerCharacterStatsScript = GetComponent<PlayerCharacterStats>();
    14.   }
    15.  
    16.   protected override void Update()
    17.   {
    18.       base.Update();
    19.  
    20.       //PlayerCharacterStats.cs
    21.       CurrentHealth = myPlayerCharacterStatsScript.CurrentHealth;
    22.       CurrentHunger = myPlayerCharacterStatsScript.CurrentHunger;
    23.       CurrentThirst = myPlayerCharacterStatsScript.CurrentThirst;
    24.       MoveSpeed = myPlayerCharacterStatsScript.MoveSpeed;
    25.   }
    26. }
    27.  
    Code (csharp):
    1.  
    2. public class MultiplayerCommands : SimpleNetworkedMonoBehavior
    3. {
    4.   [BRPC]
    5.   public void RPC_DestroyThis(GameObject gob)
    6.   {
    7.       if (gob.GetComponent<SimpleNetworkedMonoBehavior>())
    8.       {
    9.           Networking.Destroy(gob.GetComponent<SimpleNetworkedMonoBehavior>());
    10.       }
    11.       else
    12.       {
    13.           Destroy(gob);
    14.       }
    15.       }
    16.  
     
    Last edited: Jul 25, 2015
  41. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    Totally understand man, tutorials take has taken a lot of our time to do in order to explain to our developers as well. I would say that you are not inclined to fill out the tutorial as you are converting but rather that it is something you can do if you want to. You're contributions are more than enough to help some people get an understanding that anybody else who has been through the whole process is easily able to contribute to the wiki as well. Definitely really appreciate your help on the wiki and say that you should definitely focus on your game and the fun of making it and just sharing your experience with other like minded developers is just the icing on the cake. Now to get to your questions.

    1) We don't specifically explain that in documentation but mainly explain in the video that at the time you are in a specific scene that doesn't necessarily connect to the server just yet. You can buffer it by hooking into those events. So for example you have your own custom hosting script and your own manager script that is used for spawning the clients in the same scene, you then would want to make sure that you are connected to a server/host before trying to instantiate the player with that specific logic. We basically just want to make sure we are not stepping on our toes as they say it. The video tutorial is here if you didn't get a chance to watch it, hopefully it explains things a bit easier when you have time. http://developers.forgepowered.com/Tutorials/MasterClassBeginner/Buffered-Networking-Instantiate

    2) You should try and minimize the usage by checking to see if the variable you are syncronizing across the networking is something that should be handled by the server or the client. After the fact you can easily adjust your scripts into two flows that work for server or client depending on what it is. You can have multiple networked monobehaviors on children inside the parent so feel free add as many as you would like. Just make sure that the bandwidth you are trying to send can be handled on the server.

    3) I don't know if we have documentation to explain that properly but basically it is a designated folder in the resources that you set for pulling objects to instantiate from (As seen in NetworkingManager.cs Line 270). I.e. If I make a folder 'Resources/MyAwesomeFolder', I would fill in that string on the NetworkingManager Prefab to put 'MyAwesomeFolder', but if my objects that I want to instantiate are in just 'Resources/' then I would just leave it alone and it should work as normal.

    4) IsPlayer lets you logically say that this is a player object and the server to recognize its position updates, as well as to make sure to destroy it when it disconnects. It also sets the 'MyPlayer' which is a public Static NetworkedMonoBehavior in 'NetworkedMonoBehavior' to be a place to grab that object. You would want to only have one 'IsPlayer' object set as you tend to not want to override the others with it, but I could be wrong. Need to check with Brent to make sure that is the intended behavior. Otherwise it does a few things that a normal object wouldn't do.

    5) Yes, the magic of doing the Networking.Instantiate(string, recievers, position (optional), rotation(optional), <gameobject> callback) or Networking.Instantiate(GameObject, recievers, position (optional), rotation(optional),<gameobject> callback) is that you are able to tell it where to spawn and get a callback for when it has already spawned on the server. With that it is already in the right position/rotation and is already a networked object for the clients and host to pick up. The string being the game object's name based on the NetworkingManager Resources folder name (if any). This should work similar to UNET except that it doesn't need to call Spawn().

    Thank you so much for your contribution and I hope that this clarify things on your questions that you asked. I definitely like the tutorial you have put forward and I am sure that somebody else will be able to contribute to it along the way should you feel the need to take a step back and focus on your game. We put this wiki site together to have like minded developers have a place to go to, in order to share their knowledge and experiences using Forge Networking so that people can have a rich experience when they program their games.

    Thanks,
    -Brett
     
    Last edited: Jul 25, 2015
    CarterG81 likes this.
  42. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    This should be absolutely fine and is a very good practice to keep RPC calls on SimpleNetworkedMonoBehavior rather than NetworkedMonoBehavior where the simple just uses the basic line of communication and the Networked would use another layer on top of it. The variables would get synced properly to the client although I would make sure to do a

    Code (csharp):
    1.  
    2. if (!IsOwner)
    3. return;
    4.  
    Before you update your variables of

    Code (csharp):
    1.  
    2.       //PlayerCharacterStats.cs
    3.       CurrentHealth = myPlayerCharacterStatsScript.CurrentHealth;
    4.       CurrentHunger = myPlayerCharacterStatsScript.CurrentHunger;
    5.       CurrentThirst = myPlayerCharacterStatsScript.CurrentThirst;
    6.       MoveSpeed = myPlayerCharacterStatsScript.MoveSpeed;
    7.  
    in the Update(). That way only the objects that are in control of that object are allowed to sync their variables. If you want the server to handle that then you might want to take an authoritative approach to it so that the server is the one doing the validating and sending the information back to the clients. Also note that only when the value has changed, will it be synced across the network. I.e. If CurrentHealth is being set to 100 every frame, it doesn't get synced until it changes from 100 to something else.

    Hope that answers your question. Please feel free to contact support (support@beardedmangames.com) or use our forums on developers.forgepowered.com for more in depth questions like this so we don't spam unity's forums.

    =)
     
    Last edited: Jul 25, 2015
    CarterG81 likes this.
  43. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    edited: Edited example.

    Thank you very much for answering my questions. It answers most of my questions.

    I thought this would be good experience writing a tutorial, to see how much work others put into theirs. I'm glad for the greater understanding of how much work is put into good documentation / tuts.

    I do have one problem still though. A new one.

    I am having problems with isOwner. Whenever I ask if(isOwner), it always returns false. The server or client, for both spawned playerPrefabs, report "false" to isOwner.

    I checked my script compared to the ForgeCubeExample, and I don't see much of a difference. I must not understand what is happening.

    The playerPrefab is instantiated perfectly. However, on the playerPrefab, on Awake(), it checks and isOwner is always false.

    Anyway, just to be thorough, here's everything I'm doing from start to finish:
    Code (csharp):
    1.  
    2.   protected override void Awake()
    3.   {
    4.   base.Awake();
    5.  
    6.  
    7.   if (!IsOwner)
    8.   {
    9.   Debug.Log("Not Owner!");
    10.   return;
    11.   }
    12.   }
    13.  
    This always gives all instantiated playerPrefabs to be "isOwner = false" for Server & Client.
     
    Last edited: Jul 25, 2015
  44. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    Just a quick test can you try this doing the following:

    Code (CSharp):
    1. protected override void Start()
    2. {
    3. base.Start();
    4.  
    5. if (!IsOwner)
    6. {
    7. Debug.Log("Not Owner!");
    8. return;
    9. }
    10.  
    11. playerCamera.SetActive(true);
    12. }
    I believe we set the IsOwner after base.Start() on our Networked MonoBehaviors. So Awake() is really mainly for adding the variables you want to Sync over the network and setting those variables up. Otherwise you generally want to use the way I suggest above to do those logical checks. Let me know if that works and if there is still issues then I will look into it deeper.

    Hope this helps!
    -Brett
     
    CarterG81 likes this.
  45. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    Of course! Thank you, that solved everything.

    I kept thinking "They used Start, I'm using Awake." but then it still didn't occur to me the answer. I was blinded. It's so obvious now, thanks again :)
     
    Cranick likes this.
  46. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    I'm so close to getting it all working well. One last problem.

    You may want to look at my BRPC first. I may be doing something obviously wrong (again).

    I am trying to allow all connected players (Server & Client) to first select which character they want to be (The boy or the girl). Then I create the sprite and attach it to the playerPrefab via a BRPC method "CreateMyGraphic" (All names are correct in the editor.)

    Like with UNET, I'm having a bit of a problem syncing the characterName before creating the character's graphic/sprite. That is why I moved it from a regular method to a buffered RPC call. (The character graphic is not networked.) When I didn't do this, it would often create the graphic before it sync'd the character name. I tried to fix that by doing it in LateUpdate(), but it was giving me problems still.

    I figured the best way to handle it is to just call a RPC that tells everyone to create the specific playerGraphic. However, that RPC seems to be hit and miss as well.

    Code (csharp):
    1.  
    2.   void SetupLocalPlayer()
    3.   {
    4.   if (!IsOwner)
    5.   {
    6.   return;
    7.   }
    8.  
    9.   playerCamera.SetActive(true);
    10.  
    11.   RPC("CreateMyGraphic", NetworkReceivers.AllBuffered, myCharacterName);
    12.   }
    13.  
    14.   [BRPC]
    15.   void CreateMyGraphic(string name)
    16.   {
    17.   GameObject playerGraphic = (GameObject)Instantiate(Resources.Load("Prefabs/Player/CharacterGraphic/" + name));
    18.   playerGraphic.transform.position = graphic.transform.position;
    19.   playerGraphic.transform.SetParent(graphic.transform);
    20.  
    21.   }
    22.  
    I seem to have some issues with AllBuffered issues. I'm not sure if it's just my BRPC or if it's also my buffered Instantiates.

    If a carrot appears, I know the playerPrefab has instantiated. If a sprite also appears on top of that, I know the BRPC was successful. This way I have a visual representation of spawning and BRPC.


    TEST1 (repeated x3) (edit: seems to have went away- makes me think I'm insane.)
    Editor = Server.
    Add Client1.
    Server displays correctly in Editor.
    Client only displays self. Did not receive Network.Instantiate or BRPC. Server's playerPrefab has No carrot, No sprite, thus never spawned.

    TEST2 (no changes in code or project - suddenly begins to work with 1 additional client.).
    Editor = Server.
    Add Client1.
    All displays correctly.

    (edit: This is consistent. If I only ever have 1 Server and 1 Client, it seems to always work now. It breaks when I add a second client.)


    TEST3
    Then I connected more clients. The server is a standalone a build. (This doesn't seem to matter? It almost seems random.)

    EDITOR = Client#4 (Not sure it matters at this point).

    networkproblem.png


    Is there a way to debug all of this? (Seeing what goes over the network to figure out the problem?)
    I am a bit confused as to why by the end of 4 players connecting together, only the server is correct while all clients received either only some of the BRPC's or all of them plus a duplicate?


    edit: After typing this out (leaving all instances up), I tried starting Client#5 and connecting, but it froze. Tried again, same thing. After that, only the server updates its movement. All other instances no longer update their movement. They move and animate fine, but only move themselves with no update to server or any other clients.

    edit2: Test#4 was very similar to Test#3, but did turn out slightly different. (I connected up to Client#6, and Client#5 & #6 showed only 2 character sprites (BRPC) and all carrots (Instantiations))
     
    Last edited: Jul 25, 2015
  47. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    I started the server, connected Client1 (up to this point, all is always well.)
    After I connect Client#2 is when it begins messing up. So I connected Client#2 and disconnected.

    Server was all good.
    Client#1 had two sprites.
    Client#2 doesn't see Server's sprite.

    I started it up again and connected again. (this would be Client#2). Same thing happened.

    Client#1 now has THREE sprites.
    Client#2 doesn't see Server's sprite.

    Disconnected Client#2. Started up a new instance again and connected.

    Client#1 now has FOUR sprites.
    Client#2 doesn't see Server's sprite.

    So on, so forth, unto infinity.

    hmforgenetworkproblem.png
     
  48. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    Interesting, the way you have it typed out looks correct to me. I would check to verify that the Networking.Instantiate() is actually spawning your server prefab on the client. Easy way to debug is to switch the editor to being the client and letting the build be the server (At least that is how I do it when I want to play as the player and not the server). Also I would try marking your object 'IsPlayer' so that it destroys the object when it disconnects (which if the sprite is a child of that object, it would destroy it as well), or you can mark 'Destroy on Disconnect' to true.

    I can help you with this tomorrow as it is 3am here. But if you want you can zip up a simple project and send it over to me at support@beardedmangames.com and I can take a look at it in the morning! Sorry that you are running into these problems. If you want to try without my help would be to do the simple test bed of using our example scenes and just adding that same logic to them as well and seeing what happens.

    Edit: Are you using 10.9 version of Forge Networking? If not you can register on http://developers.forgearcade.com with your invoice if you haven't done so already and downlod the latest version there. Just want to make sure we are both on the same version. :p

    Thanks and talk to you tomorrow! :)
    -Brett
     
    Last edited: Jul 25, 2015
    CarterG81 likes this.
  49. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,772
    I'm using Forge 10.9 and Unity 5.1.2f1

    Networking.Instantiate is spawning the prefabs the majority of the time. Every now and then, it will miss a buffered Instantiation though. (These seems less often though.)

    I've tried the Server and Client#1 and Client#4+ on the Editor. Doesn't seem to make a difference, however it usually misses the first and second client's Instantiation only when I use the Editor as Server. (And only sometimes). When it does miss it, it is always the Server's playerPrefab that doesn't ever get sent. (Client#1 and Client#2 see each other when this happens, but never spawn the Server's playerPrefab.)

    The majority of the time though, the playerPrefabs are all successful. It's the BRPC that mess up.

    I properly set IsPlayer on the playerPrefab.

    I zipped up a simple minimal project, using the Forge example and my scripts. Along with some random images. A "player" image shows up when the playerPrefab has instantiated. The BRPC creates a "Rob" or "Joe" character graphic, depending on the player's choice. I made the "Rob" and "Joe" images transparent, so you can see whenever they receive two BRPC calls (spawn two images on the same playerPrefab). If they are darker (less transparent) then there's multiple sprites of Rob/Joe instantiated from buffered BRPC calls.

    Unless the problem is with my network or PC, you should be able to find the same problem over and over just by adding multiple clients. It's always that third client that starts the problems.

    It has the exact same problem as my project. Server and Client#1 works great. But after I start adding extra clients (starting with Client#2) things start messing up. The more clients you add, the crazier it will get.

    Anyway, thanks for the help.
     
    Last edited: Jul 25, 2015
  50. Cranick

    Cranick

    Joined:
    Nov 20, 2011
    Posts:
    305
    I responded to your email, let me know if that works for you and if so I can update our documentation to also cover that. :)

    Thanks again!
     
unityunity