Search Unity

Unity 2.6.1 Help Needed..

Discussion in 'Multiplayer' started by Klyngo3D, Oct 25, 2011.

  1. Klyngo3D

    Klyngo3D

    Joined:
    Oct 12, 2011
    Posts:
    8
    Okay Basically...

    I'm the User of a PowerMac G5 and as some of u may know unity 3.x is not supported on the PPC Processor, which kinda sucks but i guess unity cant keep making support for older hardware.

    i've only just started using unity again as i had a lil break from it to go do other things. What i need is help with creating a basic multiplayer environment in unity 2.6.1 and using smartfox as a backend, i need it to interact with a mysql database for username and password login, and then just load a basic scene with cubes as the characters localplayer and remote player e.t.c.

    Now i've found many example projects offering this kind stuff and is exactly what i need to get my project started for example... http://forum.unity3d.com/threads/105926-Basic-Setup-Unity3d-Smartfoxserver2x?highlight=Login

    The only problem is the project files have been created in unity 3 which means when i cant open them.

    i would try to do this myself but smartfox doesnt really offer any really helpful documentation on doing mysql based logins with unity.

    Thanks for your time,
     
  2. Klyngo3D

    Klyngo3D

    Joined:
    Oct 12, 2011
    Posts:
    8
    Anybody at all got any lead's on this?
     
  3. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    which sfs version ?
     
  4. Klyngo3D

    Klyngo3D

    Joined:
    Oct 12, 2011
    Posts:
    8
    Im Using SFS 2X Currently with Unity 2.6.1

    Currently.. what i have is a fork of the SFS2x FPS Demo.. i have chopped and changed quite alot with it to do what i want.. it's just the login im having trouble with.. i can see how to create a server side script for smartfox to interact with the database.. but where's the documentation on sending the request to the server and then recieveing it back in a Unity Environment. I Can only seem to find examples using AS3/Flash for custom logins.

    @appels - i found something interesting that you have made before.. would you consider sharing this with me? i see it uses SFS 1.6 which wouldnt be too much of a problem to change too as i have both installed in my Dedicated Server.

    http://forum.unity3d.com/threads/63493-Smartfox-test

    Thanks for your time :)
     
    Last edited: Nov 4, 2011
  5. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
  6. Klyngo3D

    Klyngo3D

    Joined:
    Oct 12, 2011
    Posts:
    8
    this doesnt really help me, ive written the server side login event handler but how do use it client side?
     
  7. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    On the client side you just send a login requets like allways, nothing changes at all.
     
  8. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    some code that will help :

    Code (csharp):
    1.         sfClient.AddEventListener (SFSEvent.CONNECTION, OnConnectionHandler);
    2.     sfClient.AddEventListener (SFSEvent.LOGIN, OnLoginHandler);
    3.     sfClient.AddEventListener (SFSEvent.LOGIN_ERROR, OnLoginErrorHandler);
    4.     sfClient.AddEventListener (SFSEvent.LOGOUT, OnLogoutHandler);
    5.  
    6.     public void OnConnectionHandler (BaseEvent evt)
    7.     {
    8.         bool success = (bool)evt.Params["success"];
    9.         if (success) {
    10.             SmartFoxConnection.Connection = sfClient;
    11.             sfClient.Send (new LoginRequest (username, password, zone));
    12.         } else {
    13.             loginErrorMessage = "Unable to connect...";
    14.                 ....
    15.     public void OnConnectionLostHandler (BaseEvent evt)
    16.     {
    17.                 UnregisterSFSSceneCallbacks();
    18.                 loginErrorMessage = "Connection lost ...";
    19.         .....
    20.  
    21.     public void OnLoginHandler (BaseEvent evt)
    22.     {
    23.         try {
    24.             if (evt.Params.ContainsKey ("success")  !(bool)evt.Params["success"]) {
    25.                 loginErrorMessage = (string)evt.Params["errorMessage"];
    26.             } else {
    27.                 sfClient.InitUDP (ServerIp, ServerPort);
    28.             }
    29.         } catch (Exception ex) {
    30.             Debug.Log ("Exception handling login request: " + ex.Message + " " + ex.StackTrace);
    31.         }
    32.     }
    33.  
    34.     public void OnLoginErrorHandler (BaseEvent evt)
    35.     {
    36.         loginErrorMessage = (string)evt.Params["errorMessage"];
    37.     }
    38.