• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By aymen
      please any know how can i' calculate the centroid from any number vertices
    • By Henry Fernandez
      Good day sir/maam. I am developing a game for my thesis and im done with multiplayer and plan to start the implementation of AI but i dont know how/where to start. Please give an advice. I am developing it in C# using UNITY. 
      Im am now collected all pieces that has possible moves but i am stuck on which best move to select. I hope you will help me. This is link explained the game https://en.wikipedia.org/wiki/Game_of_the_Generals 

    • By Priceman
      Firstly, hello to everyone.
      So, as the title says, i'm looking for a bit of direction for designing and programming my game idea. What i'm essentially trying to do is create a 2d side scroller along the lines of such titles as Dust: An Elysian Tail, Ori and the Blind Forest, or the Odin Sphere series. I'm currently taking courses on Udemy to learn unity and C#. I chose this route since one of my favorite indie dev studios, Ska Studios, use it making their games. I'm already a decent artist and animator, so I just need something to put the pieces together. I guess i'm looking for an opinion on if this is the best route to take for someone completely new to game development and programming. I've looked into engines like gamemaker, but for what I have in mind (progression systems, inventories, etc) it didn't seem like the way to go. RPGmaker and Unreal also don't seem to be right for what I have in mind. 
      Anyway, thanks for taking the time to help.
    • By fr0st2k
      Hello All.
      I have been working with a small team the last few months on development of a mobile RPG/gacha game, inspired by games like: Brave Frontier, Summoners War, One Piece Treasure Cruise, and even Diablo. 
      The idea behind the game is to create a fun collection game that has a good amount of strategy, with a focus on creating a true game for gamers.  Not a corporate run money grabber like the majority of mobile games.
      We have done a lot of work already on the game, however, I am at a point now where I need dedicated team members who have a passion for game development and the project.
      Take a look at some of the screenshots of the game to get an idea of where we are.
      The game involves collecting characters, and leveling them, to compete against more difficult encounters.  I took a lot of inspiration from my days playing Diablo 2.  If you boil down diablo's gameplay mechanics, you get a core game based around efficiency.  The better your items, the faster you can clear zones to the bosses, and the safer the battle with the bosses are.  After you kill the boss, you pull a slot machine lever and get more items.  The better your character(and skill), the more chances you get at pulling that slot machine lever.
      This game uses that core mechanic in a mobile environment.  Instead of running through Act3 to mephisto, you send your characters out on an 'explore' mission.  A specific amount of time goes by based on your characters power, then you fight a strategic boss fight, where you can win loot.  The explore times range from a few minutes, to hours/days.  You can speed up that time by playing a 'tap' game, similar to Tap Titans.  
      It is a great formula, and even without proper balancing, the game is already shaping up to be a lot of fun.
      --- What I need moving forward:
      Team requirements:
      1. Lead developer / Senior Programmer (unity)
      We need someone who is very fluent in unity game development, and someone who can lead a team of newer programmers. If you have been looking for a project that you can take control of, or need some resume building work that will provide a finished product to show off, this is a great position to fill, as the game is nearly complete already.
      Ideally, this candidate would be proficient in unity client and server side programming
      If you are interested in the position, we can talk profit sharing once the app launches.  (contracts will be required)
      2. Programmers
      If you are newer to programming, or just want to sharpen your skills and gain some experience on a game development team, reach out.  I'd be interested in talking to you and seeing if you are a good fit. 
      I suspect an NDA might be required, but other than that, this position would be great to hop in and out of, and again, would be a great way to contribute to a great project and gain valuable experience.
      3. Pixel Artist / Spine animator
      Either or.  I am currently getting art from a team out in Indonesia.  They are great, but hard to communicate with.  I'd love to have a dedicated artist with Spine(or any alternative 2d pixel animation) experience.  
      If you have interest in joining this team, please reply back.  Again, i'd like to reiterate, this is primarily a hobby based project.  However, it will eventually hit the app store and (ideally)generate income.  All team members will be a part of that revenue stream.
      Please respond with any questions, would be happy to respond.

    • By Nostalgic Saint

      Trap.io is a game where you collect the trap power-ups and place them and then lead the corresponding enemy (based on color) into the trap to destroy the enemy and score points.The game is endless easy to play difficult to master. The game features highly fast paced combat with an arcade-like feel to movement, to bring back the nostalgia from the past retro space shooter games. With addictive fast paced gameplay a mistake might be your last, keeping up with the fast paced flow games typically lasting 2 minutes, this game is all about fast movement and quick thinking with an element of strategy to trick your cunning, wity enemies into the traps to score points

  • Advertisement
  • Advertisement
Sign in to follow this  

Unity Data from C# does not seem to arrive.

This topic is 2806 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am completely new to C# programming but I have decent skills in C++/Java etc.
Recently I been trying to get my MMO project working with Unity3d.

On my server I print debug output in raw binary as soon as data arrives, when sending stuff from my C++ client I see the debug info displayed correctly, however data sent from Unity3d nothing does not seem to arrive.

I notice that the socket connection from Unity3d works, the server prints a message when a new connection is established. Since the connection is successful the problem is not the firewall (I tried to disable that as well to be sure).

I keep track of number sent bytes and error messages, everything seems OK.
For example after connecting and send pressing the "Account Login" button the integer totalSent is 17, which is correct:
2 byte header
1 byte msg id
5 byte string length + string (4 + "Name") a
9 byte string length + string (8 + "Password")

Here is my Unity3d that display soms buttons and handles the connection. I have been following the C# non blocking socket tutorial at http://blog.bee-eee.com/2008/09/15/c-non-blocking-sockets/.

using UnityEngine;
using System.Collections;

using System;
using System.Net;
using System.Net.Sockets;

public class NextGenConnection : MonoBehaviour {
public int totalUpdates;
public int totalReceived;
public int totalSent;
public bool connected;
Socket client;
private const int BUFFER_SIZE = 1024;
private const int HEADER_SIZE = 2;
private byte[] data = new byte[BUFFER_SIZE];
private byte[] header = new byte[HEADER_SIZE];

// Put these in an seperate header file
private const int ACCOUNT_LOGIN = 2;
private const int CHAR_LOGIN = 5;
private const int ACCOUNT_LOGIN_SUCCESS = 3;
private const int ACCOUNT_LOGIN_FAIL = 4;
private const int CHAR_LOGIN_SUCCESS = 6;
private const int CHAR_LOGIN_FAIL = 7;

public int recv;
public SocketError err;

// Putting GUI stuff here is not pretty, fix later.
Rect windowRect = new Rect(20, 20, 120, 120);

void Start () {
connected = false;

void Connect() {
client = new Socket( AddressFamily.InterNetwork,
SocketType.Stream, ProtocolType.Tcp );
try {
Debug.Log("Connecting to server.next-gen.cc");
client.Connect("server.next-gen.cc", 2000);
} catch (SocketException) {
Debug.Log("Connection Failure");
Debug.Log("Connections success");
// This must be set after Connect().
client.Blocking = false;
connected = true;
totalReceived = 0;

// Update is called once per frame
void Update () {
int test = Read();
if(test < 0)
Debug.Log("Got server data");
totalUpdates += 1;

int Read() {
return 0;

int bytesRead=0;
SocketError err;
bytesRead = client.Receive(header, 0, HEADER_SIZE,
SocketFlags.None, out err);
totalReceived += bytesRead;

if(err != SocketError.WouldBlock)
return 0;
short dataSize = (short)(header[0] | (header[1] >> 8));
totalReceived += client.Receive(data, 0, (int) dataSize,
SocketFlags.None, out err);

return bytesRead;

void Send(int msgId, String arg1, string arg2) {
SocketError err = SocketError.WouldBlock;
byte[] Id = new byte[1];
byte[] header = new byte[2];

header = System.BitConverter.GetBytes((short) 17);
Id = System.BitConverter.GetBytes((char) msgId);

while (err == SocketError.WouldBlock) {
totalSent += client.Send(header, 0, 2, SocketFlags.None, out err);
Debug.Log("Sent header!");

totalSent += client.Send(Id, 0, 1, SocketFlags.None, out err);
Debug.Log("Sent message Id!");

byte[] test1 = makeString(arg1);
totalSent += client.Send(test1, 0, arg1.Length + 1, SocketFlags.None, out err);
Debug.Log("Sent message arg1" + arg1);

byte[] test2 = makeString(arg2);
totalSent += client.Send(test2, 0, arg2.Length + 1, SocketFlags.None, out err);
Debug.Log("Sent message arg2" + arg2);

if (err != SocketError.Success ) {
Debug.Log("Send error!");

if (err == SocketError.Success) {
Debug.Log("Sent was successful");

byte[] makeString(String str) {
int strLen = str.Length;
Debug.Log("str.Length = " + strLen.ToString());
byte[] strHeader = System.BitConverter.GetBytes((char) strLen);
byte[] payload = System.Text.Encoding.ASCII.GetBytes(str);
byte [] concat = new byte [strHeader.Length + payload.Length];
System.Buffer.BlockCopy(strHeader, 0, concat, 0, strHeader.Length);
System.Buffer.BlockCopy(payload, 0, concat, strHeader.Length, payload.Length);
return concat;

void OnGUI() {
windowRect = GUI.Window(0, windowRect, DoMyWindow, "My Window");

void DoMyWindow(int windowID)
if(GUI.Button(new Rect(10,20,100,20), "Connection"))
if(GUI.Button(new Rect(10,42,100,20), "Account Login"))
Send(ACCOUNT_LOGIN, "Name", "Password");
if(GUI.Button(new Rect(10,64,100,20), "Char Login"))
Send(CHAR_LOGIN, "", "");

[Edited by - flodihn on July 11, 2010 4:37:38 PM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement