Search Unity

  1. We have added dedicated sub-forums for UNet, the experimental MLAPI and Unity Transport Package. Please use the new forums to discuss related topics.
    Dismiss Notice
  2. How can our website serve you better? Give us your feedback. Take our survey and let us know.
    Dismiss Notice

SmartFox API 1.1 released + 4 Unity tutorials

Discussion in 'Multiplayer' started by Thomas-Lund, Feb 28, 2009.

  1. CaptainKiyaku

    CaptainKiyaku

    Joined:
    Feb 8, 2009
    Posts:
    324
    First thanks a lot to both of you for your replies.

    So to sum it up, i would just let SFS handle all the verifications and don't implement another Server using Unity.

    Casting Spells, start trading, etc will be called by extensions.

    I am planning to add something like an interest grid, that splits the world into 10x10 (or more) fields and you can only see stuff that is one field around you (like you are in the middle of a 3x3 field).

    So i guess i could add a unity headless client like dreamora said, which will check the collision, and more importantly the raycasts for attacks, trades, etc., for every grid-group (probably a 3x3 field too).

    So i if i want to attack a player, i could tell SFS "hey i want to attack this player/mob", SFS will then ask the corresponding headless client if they can see each others (raycasting) and if it gives its okay, SFS will tell the client you can attack.

    I am familiar with the IT part, that's right. I am not planning to aim "MMO", it's more like playing around with it and have the opportunity to handle many users later on. But it probably won't exceed like 1000 players, which is of course not MMO, but i think using this term makes it easier to understand what kind of concept i am "aiming" for.

    Thanks again and i would appreciate it a lot if you could gimme a small thought of yours about my idea, maybe i am missing something or you have a better suggestion.

    Greetings,
    Sven
     
  2. Kane Hart

    Kane Hart

    Joined:
    May 29, 2010
    Posts:
    16
    I tried the island demo the web one comes with and SFS lite but nothing worked it gave no error server side but got some i/o client side can't connect to server with the server off it takes longer so it is communicating but maybe its out of date or something I gotta do server side?
     
  3. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    SmartFoxServer Lite isnt supported (its a product you shouldnt use in general afaik). Basic or Pro would serve your needs!

    Working on a FPS shooter example btw

    Additionally there has been the recent announcement of SFS 2 with total rewritten core (udp+tcp, optimized protocol, encryption + compression etc.etc.). There will be a Unity API for this version from launch day.

    http://www.smartfoxserver.com/2X/

    /Thomas
     
  4. Kane Hart

    Kane Hart

    Joined:
    May 29, 2010
    Posts:
    16
    So do you have to pay money to run a free game? I just noticed tons of network / server side free programs out there these days.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    No you have to pay money if you want a professionally, supported server core to drive your development instead of hack together your own.

    You won't find a solid server backend solution that has Unity support at 0 and you can't expect devs to spend hundreds to thousands of hours for your sake at $0 and I doubt you do as even you expect something in return for your game.

    Also such technologies are trivially cost wise. You are going to pay $1000++ per year to host your game anyway
     
  6. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    SmartFoxServer is free up to 20 simultanious connected users. Beyond that you have to pay a per server license.

    If you want to negotiate anything, you should contact the SFS guys. I'm only doing the Unity API and am not employed in their company.

    Beyond that - none of the systems I know for backends are free. So link me :) Always interested to see whats out there.

    /Thomas
     
  7. Kane Hart

    Kane Hart

    Joined:
    May 29, 2010
    Posts:
    16
    ahh my mistake yeah I will be checking out the Raknet then hehe I thought it was more then 20 players :p
     
  8. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    RakNet is no server backend.
    Its a network library only, the rest is fully up to you to develop, test and solidify

    Also just as warning upfront: You are looking at hundreds of hours of work if you want a plugin system and an optimized multi game environment.

    And you naturally lose the possibility of the unity webplayer due to the unmanaged code part from raknet

    You seem to totally ignore these facts on your costs calculation, which is why I reminding you.
     
  9. Kane Hart

    Kane Hart

    Joined:
    May 29, 2010
    Posts:
    16
    free game vs something silly like 100's of bucks for something I still have to run the server is just crazy... I can rent dedicated servers these days that could run some games with 1000 people on 1 single machine for under a 100 bucks.

    To me it makes no sense on the costs of it. It's also making me push towards bigworld or HE indie once it comes out.
     
  10. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    Sorry - but I second what dreamora says - all of it.

    The hardware and the software is the least of it all. The manpower needed to keep your systems secure, operating, supported etc. is going to cost you thousands of $ once you get past 100 paying customers.

    If you on top of that attempt to write your own backend server and need to support that with growing pains as you get paying customers in......

    SmartFoxServer, Photon and similar products are rock solid and faaar beyond some home hacked backend. They will save you hundreds of development hours for a very low cost.

    I realize that you most likely dont believe us. But this is all sane advice from people who have tried this before on a professional level.

    If you are into a learning experience instead, then go ahead!

    (And no - I dont get cuts from SFS sales)

    /Thomas
     
  11. Kane Hart

    Kane Hart

    Joined:
    May 29, 2010
    Posts:
    16
    I will I guess try SFS out but the thing you need to understand is that I'm making a free game of course engine costs but that was one thing hehe. Maybe they can work out a deal or I can accept donations or something but damn that is a lot of money and I do trust you guys or id be not talking to ya.

    But for a guy who is pretty much laid off example I don't work till june 15th is my next work shift who spends day and night looking for jobs I really just don't have the money.
     
  12. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    Now going totally off topic - but if you got the skills to make a game, then why make a free one?!?!?!?! Especially if you are low on cash.

    Make a non-free game, and start earning money with your hobby. Just my advice.

    Back on topic - SFS, Photon and similar are _not_ the same as Raknet. Raknet is just a network library. These other things provide you with high level APIs (on the level of zones, rooms, buddylists etc) build in. They have backend solutions for clustering, database access etc.etc. All this you need to build from scratch yourself - things you dont even know yet that you'll need :)

    Its like comparing building a house from scratch with raw materials vs. purely painting the walls in the colors you like and move in. More or less

    /Thomas
     
  13. Kane Hart

    Kane Hart

    Joined:
    May 29, 2010
    Posts:
    16
  14. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    The SFS API comes with 4 Unity examples - 3 in the API, 1 extra download. FPS demo in the works.

    Full sources and all.

    Good luck!

    /Thomas
     
  15. Robert G

    Robert G

    Joined:
    Nov 17, 2009
    Posts:
    233
    Now looking at SmartFoxServer, initially I only need a registration/login system for an online course.
    Does it make sense to use SmartFoxServer for this, or is it hilarious overkill?
    Anyway I looked at the examples/documentation but could not find a tutorial or demo of such system, any suggestions?

    Thank, Robert
     
  16. craftyfirefox

    craftyfirefox

    Joined:
    Jul 14, 2010
    Posts:
    1
    Hey RobertG,

    yes SFS is hilariously overpowered for what you need. You can do the very same thing by using simple PHP or Python Standard Webbased stuff, and make your Unity Webclient check some kind of Session (e.g. by saving a unique hash when logging in and checking that after loading the unity client).

    SmartFox is more like a full featured Multiplayer Server backend, used for as simple things as a Chat and as complex things as creating (game) rooms on the fly, handling spectator status for single games and up to MMO Serverside handling, extendable by Actionscript (for 1.6) and Java (1.6 and the new 2X) on the server side.

    But the closest thing you would need for your purpose I suppose would be this:

    http://www.smartfoxserver.com/docs/docPages/tutorials_pro/05_loginExt/index.htm

    kind regards
    Christian[/url]
     
  17. Robert G

    Robert G

    Joined:
    Nov 17, 2009
    Posts:
    233
    Thanks a lot for your answer Christian.
    Initially its kind of what I expected, then I started to do some PHP tuts and I started to research how to do things in Unity.
    That made things clear to me,…… this stuff is much easier to do by myself then I expected. So all is fine, but I will keep an eye on SmartFox one day it will come in handy.

    Thanks again.

    Kind regards, Robert
     
  18. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Thomas, I just installed SFS yesterday and spent the entire day reading all the docs and trying out the system. Loving it to bits but I have one concern. When I try the 3 demos that are on the localhost:8080 link, everything works fine... but when I try to run the FPS demo inside Unity it simply refuses to establish a hand shake...

    It connects to the server just fine but when it tries to join the default Zone it is sent an error message and it simply won't budge. I am thinking that perhaps when the project was upgraded to U3 it might have caused something to break but the code is right there... the code to connect to the server and establish a connection, it is right there and gets called so I don't know how or why the upgrade might have broken something...

    Problem is, I downloaded the sample, unzipped it and then deleted the zip so I can't upgrade again. I got one weird message when it upgraded and no amount of clicking would take me anywhere to investigate... the message didn't make sense to me so I just said "okay, sure, whatever". It went along the lines of "This object has a component that is not attached to the object. Component will be deleted"

    Have you come across any errors in the FPS demo? Any idea how I can make mine work?

    Cheers in advance

    sorry forgot to mention, installed SFSX2 Beta

    K. Turns out I didn't clear my Trash Can so I tried again. I am including some images to explain my problem. I would greatly appreciate any assistance you could offer :)
     
    Last edited: Feb 5, 2011
  19. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Okay, so I took the source project for the sample that comes with SFS and played with that lobby code and turned t into a prefab and exported it as a package to import into the FPS demo.

    Now I no longer get those error messages but when I log into the localhost, nothing happens... but if I connect to the ... well, not sure if I am on to something here, but it seems the game is trying to connect to 109.254.37.15 but when I ping that address I get 100% package loss...

    Is this demo's server side disabled or something?
     
    Last edited: Feb 5, 2011
  20. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    UDP connection refused :)

    Several causes to that one:

    - you forgot to enable UDP on the SFS2X server. The FPS example comes with a nice PDF and on page 1 it tells you to use the admin tool to open UDP listening on the server

    - you need to set the server (again in the admin tool) to listen on external IPs. Default is localhost only for security reasons

    - you are running firewalls blocking UDP. UDP is a bitch sometimes to get through firewalls. So possibly you need to open it in your router/windows firewall

    /Thomas
     
  21. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    Hey man, thanks for the info. Did you say there is a PDF? I thought it was weird that the project just comes with 2 directories: SFS2XFPSextension and SFS2XFPSTutorial and just leaves you to fend for yourself... But I cannot find the PDF... is that a separate download from the website or is it hidden somewhere in the folders?

    I noticed there is a fpsExtension.jar file that looks suspiciously like it needs to be setup...
    Anyways, I am including two more images for you. The first one shows my router config. It seems to be okay... My router states that unless a rule pertains to data being received, the DEFAULT rule is used (which blocks everything) so I set it up to allow for any traffic from that IP to always be allowed...

    Then, whenI tried to setup the ip in the admin tool I was not able to type in the IP so I went to the config.xml and set it up there. So now the IP appears in the admin tool but when the server starts up it just tells me that it couldn't load it.

    I am now at a level where I can login to the game and it loads the Game scene but as s0on as that scene load, all I see is the skybox, no terrain or anything else, just the cursor in the center of the screen saying "Dead. Wait for respawn counter" then the time in the top left just counts off like mad but nothing else happens. I have no control over anything and nothing shows up... I feel I am getting close...

    The fact that I no longer get UDP error messages is a bonus BUT I am using 127.0.0.1 for that... when I use 109.254.37.15 the smartFox.Connect(serverName, serverPort); command does not generate a response...

     
    Last edited: Feb 5, 2011
  22. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I just did a file search on the zip file and I find no PDFs :(

    I just downloaded the WhitePaper... that seems to be it... Now to go work through that... Thanks for that :)

    Edit:
    Okay, so the only thing I noticed that was different from what I had done on my own is that I placed the extension in a folder calledFPS whereas they uses sfsFPS so I placed it in there and restarted the server. Didn't change anything in the configs or anything but now I am able to get to the screen where it tells me to select the max number of players. When I click on that button it then gives me the UDP error again. This time , though, on 127.0.0.1.

    Tell me, this IP 109.254.37.15... I didn't type that in so I have no idea where that came from. I assumed one of the script files did that. Is this a fluke or is that an address I am supposed to use for this demo?
     
    Last edited: Feb 5, 2011
  23. Thomas-Lund

    Thomas-Lund

    Joined:
    Jan 18, 2008
    Posts:
    465
    Hey - yeah. The pdf is separate download right next to the code. http://www.smartfoxserver.com/2X/download.php Seems you've found it.

    For the server config you want to use the IP of your servers netcard - not your external router ip. 192.168.*.* typically. The server tool should show what ips are available on the box as a dropdown (if I remember correct).

    Try to generally first use 127.0.0.1 and run the server locally. Once you are certain that you got that working, you can mess with routers and firewalls and stuff afterwards. Makes it all easier to take it in smaller steps.

    Also run the game from editor first - and then later webplayer. Because else Unity security mechanisms for webplayer starts to mess with this too :-D

    /T
     
  24. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    I think this was probably my biggest mistake. I figured that other IP address was similar to the Unity Masterserver IP where there is one exact IP address that we can connect to to start our network games. When I noticed an IP address that I didn't enter I figured it must be a default IP used with this specific game demo... That was where my confusion came into play. I thought that IP was one I HAD to use for the demo but it didn't show up on the drop down list...

    I was thinking I should just stick with localhost since that was what the docs said. Seems I was right with that. The only thing I cannot figure out now is why everything is working 100% perfectly up to the part where the game level is supposed to start... right there I get a UDP error and I fall into a "create new game - select game name - create new game - select game name - create new game" -loop.

    I am just desperate to see this working. Don't care about web player, standalone or editor or whatever. Couldn't get it to work in editor, so no matter how else I try running it it won't work since I don't yet have a VPN to run SFS on. My only option right now is local... so the editor HAS to work... and does work... right up to the point where the actual level is supposed to load... :(
     
  25. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,686
    that seems like a UDP issue, make sure your not blocking the ports and that they are configured in the config tool of SFS.
    if you can take a screenshot of that screen and post it also.
     
  26. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    You mean this screen? On my machine itself, my firewall is turned off so that shouldn't be causing any interference...

    Edit: HELLLLO!What do you reckon could be causing this little friendly visit?
     

    Attached Files:

    Last edited: Feb 5, 2011
  27. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,686
    your getting a udp ok first and then an error. looks like another problem but i wouldn't know what is causing that
     
  28. MrDude

    MrDude

    Joined:
    Sep 21, 2006
    Posts:
    2,569
    This is just getting weirder and weirder...
    I now have it working just fine but I don't understand why...

    The problem was I had to change the Zone to another Zone. So I compared what the difference was between GameLobby and SimpleChat and the only difference I could see was that one had the default group setup to contain "game" while the other one had it setup to contain "games"... So I changed it to also be game, instead of 'games' and now both zones work perfectly... Go figure... especially since all the rooms in all my zones are all marked to either NOT be linked to a group, be linked to 'default' or to 'ThievesGuild'... so why changing 'games' to 'game' makes a difference I don't know...

    So I go scan the source some more and I find that the "Create new game" option actually creates a room dynamically...
    Code (csharp):
    1.             RoomSettings settings = new RoomSettings(roomName);
    2.             settings.GroupId = "game";
    3.  
    4.  
    Mystery solved... oh no wait, no it isn't... So if I join a Zone that doesn't have public and/or default groups setup with the same group ID as a dynamic room, then I can't create that room? I thought the groups were an extra feature to make sending data over the network more efficient by sending stuff meant for a specific group ONLY to that group... does this mean that rooms with IDs receive ONLY data meant for that group and nothing else? So if a message is broadcast to the entire zone to say "A new room was created", only groups specified by the zone will receive notification of the new room? Is that correct?

    Anyways, as long as it works, that is fine... but when I try to configure a zone of my own and setup rooms in there that I want to use instead of creating them dynamically, that brings up another kettle of fish, but at least I think I am now able to troubleshoot myself into the blue (eventually) but this leaves only one more interesting thing...

    Once I log in, I get a valid UDP message and then 8 seconds later I get a failed message. Inspecting the code again it turns out that this line
    Code (csharp):
    1. if (evt.Params.ContainsKey("success")  !(bool)evt.Params["success"])
    inside function OnUdpInit(BaseEvent evt) fails at the second test. success is 'false'. Now what confuses me about this is the fact that it is called 8 seconds after I passed the test. The InitUDP is only called in the OnLogin function so it should only be called once... why is it being called twice? So I assume it must be the activity timeout on the zone but that is set to 30 seconds and 300 seconds, not 8 so why then does it get called twice?

    More importantly, wether I create the game before or after I get the failed UDP message, the game still starts... and to top it all off, if I create the game before I get the failed UPD message, I don't get the message... so it only happens if I stayed logged in for 8 seconds or more without creating a new game... Bloody weird this is...

    But at least I got it working so that is a bonus. Thanks for the help guys. Much appreciated. :)
     
  29. fabioColombini

    fabioColombini

    Joined:
    Dec 9, 2013
    Posts:
    27
    Does SFS API works in Unity web plataform?
    I have a game working correctly in PC and mobile, but when I generated for web, I can´t get it connected.
     
  30. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,686
    Yes but you need to prefetch the socket policy before connecting due to webplayer security.
    Check the docs.
     
unityunity