Is it possible to use IPC to create a connection between a c++ class(e.g. player controller) and a external process?

Yes, an unreal actor is just a C++ class.
You can call some library to open up IPC (maybe a UDP socket) in the controller.
Inside the Tick() for the controller, you can service the IPC, say by calling recvfrom(). (especially if the socket is non-blocking).
You can then sendto() the socket on whatever port it’s bound to pass data to the controller.
If you want to use TCP or gRPC or some other mechanism, it’s the same general idea: make the controller set up whatever it needs to do to listen, and poll the RPC/IPC mechanism inside Tick().

That being said, if you want to use multiplayer, you’ll have to figure out whether you want to listen on the client, or on the server, and if multiple controllers listen on the server, they can’t all bind to the same port, for example. This is all standard IPC stuff.

The main two things that are important:

  • Unreal can call arbitrary C++ code, but you may need to wrap that code behind some library API, because including system headers directly inside Unreal dependent code doesn’t always work well
  • Tick() is a reasonable place to harvest whatever IPC messages come in. You should make that be asynchronous – either use non-blocking I/O, or spawn a separate thread to accept/read/decode messages, and put them in some kind of queue that the Tick() function dequeues from.
1 Like