Search Unity

ConnectGui from Network examples.

Discussion in 'Multiplayer' started by mehware, Dec 23, 2007.

  1. mehware

    mehware

    Joined:
    Nov 19, 2007
    Posts:
    739
    Hi,

    I integrated some of the network code (Third Person Code) into my project. I am able to create a server.

    I enter my ip and leave the port alone. I hit connect and it says I can't connect are you sure your The connection request to myip:port failed. Are you sure the server can be connected to?

    Any ideas.

    I am able to be the server and the client for Unity's Network example.

    Does it have something to do with the port?
     
  2. lilliendal

    lilliendal

    Joined:
    Nov 7, 2007
    Posts:
    4
    hi there i have the same problem here ?
    dunno what is wrong?
     
  3. mehware

    mehware

    Joined:
    Nov 19, 2007
    Posts:
    739
    I get the same error using the GuiConnectMasterServer script. I am able to create a server, then as a client see the server in the list it logs connection failed are you sure your able to connect to myip:port.
     
  4. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    280
    Are you guys using the same instance of Unity to act as a server and client? Unity does not support a server and client on the same instance (at the moment). Each one resets the network interface. You can deploy and run or use a separate instance of Unity with an identical project.

    Also, make sure run in background is enabled (Edit->Project Settings->Player and Application.runInBackground). If this is not enabled and you switch from a server instance to a client instance, the server will be asleep and not respond to anything.
     
  5. mehware

    mehware

    Joined:
    Nov 19, 2007
    Posts:
    739
    Yeah I have had that setting on (run in background)

    Here is my log.

    Code (csharp):
    1.  
    2. This machine has a private IP address
    3. UnityEngine.Debug:Log(Object)
    4. ConnectGuiMasterServer:Awake() (at Assets/Networking Scripts/ConnectGuiMasterServer.js:48)
    5. Connected to master server at 83.221.146.11:23456
    6. Connection Tester reports NAT target 83.221.146.11:10735 not connected to NAT facilitator 83.221.146.11:50001.
    7. Connecting directly to host
    8. UnityEngine.MonoBehaviour:print(Object)
    9. ConnectGuiMasterServer:MakeWindow(Int32) (at Assets/Networking Scripts/ConnectGuiMasterServer.js:201)
    10. UnityEngine.GUI:BeginWindows(Event, Int32)
    11. The connection request to myip:21939 failed. Are you sure the server can be connected to?
    12. ConnectionFailed
    13. UnityEngine.Debug:Log(Object)
    14. ConnectGuiMasterServer:OnFailedToConnect(NetworkConnectionError) (at Assets/Networking Scripts/ConnectGuiMasterServer.js:30)
    15.  
    Myip is the ip I get when I go to a site like whatsmytip.com. I have been trying to "open" my NAT and doing as much reasearch on networking as I can. I am running Unity from a built application for say the server, and the client application in a web browser. So its two instances.

    Also is the TPS-Auth example does the server just see the scene and the client is able to spawn a player and move around?
     
  6. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    280
    Do you have a public IP address for your machine? If you have a NAT'ed or private address, connecting to your public IP and port directly will not work (which the log indicates you are doing). You need to use NAT punchthrough in that case but also that will not work if your machines are on the same local network or if this is all on the same machine. If you are running this (the two instances) on the same machine try using the localhost address, 127.0.0.1. If not but you still have your machines on a local network, use your IP address as reported by the ifconfig utility or System Preferences->Network.

    The master server returns private IP addresses if it detects a server and client are on the same network. The connectGuiMasterServer script in the Network example project demonstrates how it can be used.

    TPS-Auth is a server authoritative example with a dedicated server. The server only runs as a server, not also as a client. So yes, only clients which connect to the server actually spawn players.
     
  7. mehware

    mehware

    Joined:
    Nov 19, 2007
    Posts:
    739
    I have my Windows machine running as the dedicated server (for the TPS-Auth example).

    I connect to it as a client from my Mac. I am able to connect, Yay! However when I click on spawn player it does not spawn a player.
     
  8. mehware

    mehware

    Joined:
    Nov 19, 2007
    Posts:
    739
    I am able to get the player to spawn now. There are three problems.

    One, He doesn't get hooked to the followspringcamera.

    Two, when I move he moves back to his original position which I'm thinking is where the server thinks he should be.

    Three, the local player dialog window does show however no values show, which I am thinking are screwing up problem two.

    All I did really was strip the other demos out and leave it as TPS-Auth. Carefully of course!
     
  9. mehware

    mehware

    Joined:
    Nov 19, 2007
    Posts:
    739
    Sorry to beat a dead horse :p

    I finally got the TPS-Auth demo working and the other demos stripped away. Everything is working everythings great.

    I went on to extend the chat system to include who sent the message and display its name (be it the client or server). I tested it with a server and two other clients it worked great.

    Now when I spawn a player on the client side hitting the spawn button, the client does spawn but goes through the ground and continues to fall in a weird motion.

    Any ideas what would be causing the spawned player to go through the ground. Thanks in advanced.
     
  10. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,108
    I haven't looked much at the examples yet, so apologies in advance if my post is redundant.
    However, when it spawns, does it have all the components you would expect it to have? It sounds like it's missing some physics related component?
     
  11. larus

    larus

    Unity Technologies

    Joined:
    Oct 12, 2007
    Posts:
    280
    I took a close look at the project and noticed a certain change in the format of the animation and model files caused the player prefab to break in the TPS-Auth project. This was something which was done for cosmetic reasons when he project was finished and the foul up went unnoticed. I've fixed the problem (new project can be downloaded from the resource section now), maybe if you add your chat system improvements now, the player won't fall through the floor. Sounds like some network view or another component in the player prefab is not working as it should.