I'm building a Unity3D client in C# for a multiplayer game that I made. The server is written in Node.js, and I wrote a web client in Javascript that works well. But I am running into lag issues with my Unity3D client implementation. I am using the websocket-sharp library, but have been unable to use it in the same way as I did on my Javascript client with the HTML5 Websocket class. I believe the issue lies in the way the websocket-sharp library is made, currently each Send() will cause a lock to _forSend, so the data will transmit like this:
data1:frg1
data1:frg2
data2:frg1
data2:frg2
...
But on my working javascript implementation, it looks like this as it is truly multithreaded:
data1:frg1
data2:frg1
data2:frg2
data1:frg2
Therefore I believe this is the cause of my lag with my C# Unity implementation, because the websockets-sharp library behaves like this. Can anyone confirm that this is an issue with the websockets-sharp library or suggest a library that would work?
you can see my simple SignalR unity client and create simple one for your node.js server, then see if the lag still present or not. https://github.com/Mo-Rahemi/WebGlGameWithSignalRClient
from my experience the lag should happens because of :
if your fps is low then java script calls affects too.as unity is single threaded and Webgl not support C# threads you have to handle incoming update in unity main thread. let say your server send update every 50 ms, so you have 20 java script call per second, so if your fps is under 20 frame per second your game go behind the server.
if your server update rate is too high it would be the problem because of tcp protocol of websocket ... .
interpolation, if your server sends 20 update per second depend on your player move speed you may have jumping issue in game client. so you must first queue them and interpolate between updates smoothly.
as websocket-sharp is a known library i think it shouldn't be problem, perhaps you are using it in bad way but we need see the code sample to help.
I used Socket.IO for Unity in my project and it work. I implement to create notification for my game example when someone aware a gilf ....
https://www.assetstore.unity3d.com/en/#!/content/21721
Related
Does anyone have an idea of the performance difference between .NET for python and just setting up a UDP server for communication between python and Unity? I've tried ironPython but it only supports python2 which is dead now. I need to run python functions for each agent I instantiate in Unity and grab their states as they update to animate in real time.
Currently im trying to make a lobby system for my game, the lobby system seems to have quite a few issues but im slowly working my way through them. I cannot however, find out a way to make the host automatically get added as a player in the game, when he starts a server. There will never be a situation where the host will only act as the server, so i need him to automatically get added to the game.
I have tried a bunch of different things with ClientScene.AddPlayer() But i cannot make this work.
Further, i cannot find any documentation on what functions the different buttons on the standard unity network lobby hud actually do, so i have a hard time replicating the behaviour.
Anyone has any good sources /ideas on the issue?
There is a method in the given NetworkManager called StartHost(). Try this for starting the server.
See the Scripting API for NetworkManager.StartHost() and all the methods from the NetworkManager
You have to write a custom UI and network manager to eliminate the Start Server GUI option which is by default provide by the Unity Networking GUI component. You can view this simple tutorial (UI & Custom Net Manager) to understand it.
I have a Control Panel (lots of buttons) which works on all platforms.
I want that Control Panel to be shared with everyone (PC users, Android users etc).
Once a person press a button, all of the users Control Panels will be updated.
How do I approach this issue?
Dedicated server with clients?
I'm looking for a block of code which handle sending/receiving data/click on a button.
The whole program written in Unity C# and I'd like a solution in this platform as well (if possible).
socket programming is cross platform. you just send and recieve bytes. you just should have a server to recieve data and send it to other devices. if you use c# you can use .net sockets but for get rid of syncing problem yu can simply use unity Network library and using RPC. now unity has new network system named UNET and there is also photon. photon is not made by unity technologies but as the api is written for many different platform it can be the best choice for you to work on.
The Problem:
I'm writing an application that needs to receive electrical input from a machine every time the machine does something.
I have a Limit switch set up to the machine and it currently completes a circuit every time the machine does it's thing
I need it to input into a computer using usb as oppose to just complete a circuit.
I had a dataq 'dl-148u-sp' And i got the c# code to produce a graph using ActiveX controls but all i really need is the digital output from the circuit being completed (which for the life of me i couldn't figure out how to do)..
I ended up frying the device(i think) even the software it came with doesn't recognize it anymore...
I need a new device, and it turns out they discontinued the one i had, and the next one up after shipping is like 90$.
The Question:
Is there a Better/Cheaper/Easier way of doing this? Or can anyone suggest a Good device that's easy to get the output using c# code so i can incorporate it into a program i made?
It's not clear if you are asking for a hardware or software solution here. Are you asking what the best way to facilitate that data transfer from your machine to the PC? If so, this may not be the place to ask, but you might look at a USB to GPIO module.
http://numato.com/8-channel-usb-gpio-module is an example.
I'd recommend an Arduino:
http://www.arduino.cc/playground/Main/InterfacingWithHardware
They dev kits are cheap and there's a ton of open/free libraries that interface the Arduino to C#.
More expensive and complex board is IOFirebug with c# library and many functions. Input voltage range is from 5V to 30V.
I'm implementing software to casino auto-play. I'm using .NET technology and C# language.
The main problem is how to capture data from casino game (here is the link to the game http://www.bet-at-home.com/redirNetentCasino.aspx?game=lrblackjack2-3h&pff=True ). I have never been dealing with Flash so I don't know a lot about this technology.
Well, I know that In the game we have server and client. Server is sending data to client and client is responding. For example server is sending information about dealt cards. My question is it's possible to capture data sent by server to client, I quess it is?? I need to now what kind of card I'm receiving. This data is sent in readable format or is ciphered?? Could you give me some hints?
The second option is to use a screen capture.. but this is very slow method. What are you thinking??
Thank you for help.
Regards,
Pablo
There are a couple of things you can do to interpret data from the game. First, you can use CheatEngine which is mostly the choice of Flash game hackers. The following links will help you get started:
How to hack flash games with cheat engine 5.5How to Cheat and Hack Flash based Games
The above method will not work for server based games like the ones hosted on Facebook. So, your second choice is capturing the network traffic and see what you can gather to attain the required information. For capturing the network from C#, you can use Pcap.NET. But before you try to do it programmatically, you should try it doing using Fiddler, which gathers plethora of information for you whenever you surf a website or when a plugin like Flash makes use of web.Get Fiddler and GL !