I am running a Unity Game on a PC (for development purposes) and then on an Android phone (for production). I need to send data to the Game continuously from a WiFi enabled microcontroller (Esp32). Is it better for me to use UDP or Websockets for data transfer? What are the pros and cons of each method? In this scenario, the game device will act as a mobile hotspot while the esp32 will connect to this hotspot.

  • \$\begingroup\$ To clarify: Does the game act as a server or as a client towards the microcontroller? \$\endgroup\$ – Philipp Jul 3 '19 at 8:07
  • \$\begingroup\$ @Philipp the game is the client and the microcontroller is the server. \$\endgroup\$ – Nadim Ahmed Jul 3 '19 at 8:08
  • \$\begingroup\$ Do you already have an implementation of the Unity LLAPI network protocol which runs on that microcontroller or will you have to program that from scratch? \$\endgroup\$ – Philipp Jul 3 '19 at 13:50
  • \$\begingroup\$ @Philipp I don't know what that is. My board supports basic Websockets and so does unity. \$\endgroup\$ – Nadim Ahmed Jul 3 '19 at 14:01
  • \$\begingroup\$ The problem is that Unity doesn't give you direct access to Websockets. It wraps messages in its own protocol on top of the WebSocket protocol (it acutally gives you multiple protocols to choose from). You would have to implement one of those protocols yourself. Unfortunately the whole world of Unity Networking is currently in a state of flux. The old API is deprecated, but there is no replacement yet. \$\endgroup\$ – Philipp Jul 3 '19 at 14:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.