1
\$\begingroup\$

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.

\$\endgroup\$
10
  • \$\begingroup\$ To clarify: Does the game act as a server or as a client towards the microcontroller? \$\endgroup\$ Commented Jul 3, 2019 at 8:07
  • \$\begingroup\$ @Philipp the game is the client and the microcontroller is the server. \$\endgroup\$ Commented Jul 3, 2019 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\$ Commented Jul 3, 2019 at 13:50
  • \$\begingroup\$ @Philipp I don't know what that is. My board supports basic Websockets and so does unity. \$\endgroup\$ Commented Jul 3, 2019 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\$ Commented Jul 3, 2019 at 14:22

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.