Search Unity

Please, help with SFS and Unity - players cant see others

Discussion in 'Multiplayer' started by xandeck, Sep 9, 2009.

  1. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    Hello all,

    please, could someone give me a direction?
    I'm using SFS with Unity, so far was ok... I used the Island Demo to make my scripts... I made a custom login process that works with my database in MySQL, the player logins, it enters in a Room created via extension in SFS, it returns the roomlist this same way and then players can chat in a new scene.

    When players click at TEST BUTTON a new scene loads and they enter (via extension file in SFS again) into another room, spawning the player objects into the scene, same way like the scripts from SFS Island demo (but I changed the joinning room THe Gardem at the NetworkController script).

    When first players connect he can see the others players that connected too... but the new players cant see (visually talking) the players that were already logged in. o_O... only new players connected.
    I can see in Debug window (messages) that all players are sending and receiving datas normally, the new players just cant see the old players connected.

    I made some search in my scripts (same as the Island demo, I just changed some variables names - all are correct, I checked all over) and I think the problem is here:

    Code (csharp):
    1.  
    2. ...
    3. ...
    4.         private void SpawnRemotePlayers() {
    5.         SmartFoxClient client = csFase_NetworkCORE.ConexaoCliente();
    6.         foreach (User user in client.GetActiveRoom().GetUserList().Values) {
    7.             int id = user.GetId();
    8.             if (id!=client.myUserId) SpawnRemotePlayer(user);
    9.         }
    10.     }
    11.  
    I think it is not recognizing the client.myUserId... but I setup this up into my other script, during the login process, when receiving the response from SFS extension:

    Code (csharp):
    1.  
    2. ...
    3. ...
    4.  
    5. Room room = smartFox.GetActiveRoom();
    6. User user = room.GetUser(name);
    7. smartFox.myUserId = user.GetId();
    8. smartFox.myUserName = user.GetName();
    9. message = "Logged in with sucess as " + smartFox.myUserName + " (ID: " + smartFox.myUserId + ") in Room: " + room.GetName();
    10. UnregisterSFSSceneCallbacks();
    11. Application.LoadLevel("Lobby Room");
    12.  
    My code above works, the message variable returns the true name and ID of the player connected (I checked into the Admin plugin of SFS), because as says in manual, the myUSerName and myUserId must be set manually using custom login with SFS.

    My real question is: using custom login script I need to change some directions in my script, like set the myUserName and myUserId manually... same for the RooMList, I need to send it via extension file, because the ones into the SFS API in Unity does not work... what maybe I'm doing wrong?

    Sorry the long post... I'm just a little bit lost...
    The major changes I made into the SFS Island Demo was change the login process (its custom) and how players join rooms (it is via extension files), the rest of the code is pretty much the same...
     
  2. dragonjack

    dragonjack

    Joined:
    Jun 15, 2009
    Posts:
    48
    Hi!I have same problem too.Someone help us please!thx
     
  3. xandeck

    xandeck

    Joined:
    Apr 2, 2009
    Posts:
    563
    Hey bob, I manage to solve this 2 days ago :D


    I use a custom login script... then I return the roomlist via server side (cant do this in UNity side only, because of the custom login I think).

    Then my player enters a room already (in server side script), I say this is a lobby room only. In the lobby room the player can create rooms or enter created rooms.

    So I changed the scripts of the Island demo to fit my own needs, because when player clicks start he changes the Scene and then I check manually, via extensions, what needs to instantiate and what I dont need.

    Remember to set the myUserName and myUserId manually (I did this by searching my own player in the room I was and then get my username and find this data).

    I spent some time trying to discover all this (I dont find much help here with SFS nor in the SFS foruns...).