Get socket information through UE4?

Ok, this is kind of a simple yet complex question. Is it possible to connect to sockets through UE4? I’ll explain a little further. I’ve been working on a virtual reality glove for a while now in unity, and I’d like to allow it to be accessible in UE4 as well. I’m doing simple serial communication to send the data from an arduino device to the computer using standard socket communication. This works fine in unity, but I was wondering if there is support for that kind of thing in UE4 through easy means, such as blueprints. I guess it there are probably libraries I could use and make a custom build of UE4, but I’d like it to be as simple to the end user as possible, so using built in stuff would be the best. Any ideas? (**Note, I can program just fine in c#, but for whatever reason, c++ bugs me any time I try to learn it, so I keep putting it off, thus, I don’t know C++)

For those interested, here’s a video of the glove “mostly” working in unity:

It’s meant to be a companion piece to the oculus rift, and if I get it working without drift, and make my own flex sensors, it could be the first vr gloves that are actually affordable. (I don’t consider the $600 control vr gloves to be near affordable. If I can get it how I want, we are talking less then $100 at retail for both gloves)

Anyway, thanks for any help in this part, I really appreciate it.

That’s really awesome.

I’m extremely interested in this sort of thing, as I’d like to have hand/finger motion support for my VR game. I haven’t done much work with UE4’s C++ but I am experienced in it.

If someone that knows how this is set up typically in UE4 can reply here and point in the right direction, I’d be interested in helping get started integrating it OP.

Hi Caliber,

Unreal has a socket abstraction named FSocket. Here’s a tutorial on it http://www.osnapgames.com/2014/05/24/connecting-to-a-third-party-socket-server-in-unreal-engine-4/

[edit] Noticed you mentioned serial as well as sockets, so I’m not 100% sure what you’re looking for (if the Arduino is talking directly to your program then it’d probably be the via USB VCOM port, as opposed to a network socket). We don’t have a wrapper around COM ports currently, although it wouldn’t be too hard to add as a C++ plugin.

Cheers,
Michael Noland

O-o… -_- it is serial port I’ve been using. For some reason in my head, they were interchangeable when writing the post. For example my connect code is this:



		SerialPort serial;
		serial = new SerialPort(comPort,speed,Parity.None,8,StopBits.One);
		serial.DtrEnable = true;
		serial.ReadTimeout = 1000;
		Thread.Sleep(100); //allow time for settings to be set. Unity has issues without this.
		currentLine = "trying to open";
		serial.Open();
		currentLine = "Opened port, entering loop";
		serial.WriteLine("1");
		//rest of the logic for serial reading and such here.


This is actually threaded in unity, so is pretty cool and doesn’t effect the speed of the game at all. (data is sent back to unity using delegates, so it’s also thread safe)

Getting this kind of thing (serial) working in unreal is what I would need. Eventually this will probably be a bluetooth device instead of usb, to make it wireless. -_- it’s actually quite the pain to use with all the wires from prototyping it. I don’t think sockets would actually work due to latency, (through the network) nor do I even know if bluetooth would be fast enough. It’s still in early development stages, so trying to find the fastest thing is key.

It’d honestly probably be better to use pipes to a dll or something (driver?) so that the game wouldn’t require any updates, just the driver to get better accuracy and such (like better drift compensation). I’ve gotten pipes working with unity, and the program would send over 7,000 instructions through the threaded pipe per second in a basic scene, so latency would be fine. O-o Any ideas on this? (Perhaps I should have placed this post in the vr subforum)

It’s probably a little more work up front, but you might consider researching VRPN. It’s a standard that has been used in research VR for a long time to hook up different devices, etc… I think there have been a few other threads on the forum with other people who are interested in integrating it into the engine. As a result, your device would be compatible with UE4 (if/when people get a VRPN plugin done) as well as any other existing software that supports it.

http://www.cs.unc.edu/Research/vrpn/

Cheers,
Michael Noland

Hi Michael , can you provide some example code or links to show how UE4 communicates with com ports please? I have c++ codes that can read com ports, however there are a lot of stuff related to windows api(a lot of stuctures and that kind of stuff), I can’t translated it to UE4 C++. I’ve tried to compile it to dll, and it brings more trouble. Thanks in advance.