- Home /
Can unity send an output to an external device?
Hi I wonder if it is possible to send a signal to an external device vai USB. For example if my player took damage could an output send a signal to the usb device, even say if it was a usb light that flashed evreytime a player was shot.
I really want to hook up my electric shock quazzar gun to the game so when you take damage you get a shock.
Any ideas? Thanks ..
You could try messing with the ideas outlined at the following URL:
http://www.developerfusion.com/article/84338/making-usb-c-friendly/
It goes over how to interact with a USB device by treating it as a file stream and reading and writing raw data to it. It may not work, but you could give it a shot.
DISCLAI$$anonymous$$ER: I've never worked with this particular set up and it is entirely possible that you could cause damage to the device by writing incorrect data to it.
Answer by aldonaletto · Nov 29, 2011 at 01:14 AM
You could use the C# SerialPort class to communicate with serial devices, like a FTDI USB module or an Arduino board. A simple and useful FTDI module is the DLP-IOR4: it connects to USB but appears to the system as a serial port; this module has four relays that can be controlled by sending single characters to the serial port:
Another alternative is the DLP-IO8-G module: 8 channels that can be individually used as digital outputs, analog or digital inputs.
Anyway, you would have to use the SerialPort class; take a look at this answer, where Unity communicates with an Arduino board (microcontrolled USB board) - once the COM port is open, sending single character commands is an easy task.
[4]: http://answers.unity3d.com/questions/179311/unity-to-arduino.html
[6]: http://answers.unity3d.com/questions/179311/unity-to-arduino.html
Answer by jahroy · Nov 29, 2011 at 01:15 AM
That should be totally possible.
You can basically do anything that .Net allows you to do, so google away and enjoy!
Here's what I get by googling c# usb communication:
Your answer
Follow this Question
Related Questions
Make a motor turn in real life. 0 Answers
Connecting an external NFC reader with Unity 2 Answers
Problem identifying USB 0 Answers
Possible to use an external camera (USB) while running on Android? 1 Answer