Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

physical computing with unity!

Discussion in 'Multiplayer' started by konzeptzwei, Feb 28, 2008.

  1. konzeptzwei

    konzeptzwei

    Joined:
    Feb 10, 2006
    Posts:
    64
    hello folks!

    the question i have is not a typical "multiplayer networking" but "networking" one.
    i hope somwebody can help me. i want to work with pysical interfaces that you can find on www.phidgets.com.

    these interfaces are pretty cool because you can connect them directly to your mac via usb. they have crossplatform software that you can use. the driver has even a webservice that you can connect to.

    now there's my problem. the webservice sends data on port 5001 and i tested this with the terminal: "telnet localhost 5001" as a result i receive: "connected to localhost". now i know that the service works.

    now i tried the same with unity. i put the following code on a gameobject:

    - -
    var port = 5001;

    function OnMouseUp () {
    ConnectToServer();
    }

    function ConnectToServer () {
    Network.Connect("127.0.0.1", port);

    }

    function OnFailedToConnect(error: NetworkConnectionError) {
    Debug.Log("Could not connect to server: "+ error);
    }
    - -

    unfortunately i get three error messages:
    1. "Running as a client. No player ID set yet."
    2. "The connection request to 127.0.0.1:5001 failed. Are you sure the server can be connected to?"
    3. "Could not connect to server: ConnectionFailed"

    it seems that i did not understand how the networking concept in unity works. would be nice if somebody could shed some light on this even if this is not a "multiplayer" issue.

    thanx.chris
     
  2. jeffcraighead

    jeffcraighead

    Joined:
    Nov 15, 2006
    Posts:
    740
    The Unity multiplayer networking uses a specific (undisclosed) data structure for communication between other instances of Unity only. To do what you want, use the .NET System.Net.Sockets library. Search for threads on this, there are quite a few that have a good explanation + code of how to connect to other computers or devices.