#Communication between Unity and Python

1 messages · Page 1 of 1 (latest)

summer elk
#

Hello, I'm trying to implement a functionality for my thesis. Basically, in ML-Agents, the observations made in the Unity environment are sent to a neural network through a communication bridge. What I want to do is implement a hook that intercepts these observations and sends them to an LLM instead, but I can’t quite figure out how the communication between Unity and Python works, or how I can redirect the observations to another module instead of the network. Do you have any idea?

untold nebula
#

Aside from that, web requests, named pipes.

#

Depends on the OS too. Pipes are on windows only. Other OS might have a similar feature.

summer elk
#

but i have to redirect the traffic from unity to python, right? i remember for sockets you should specify the port number, or something like that. so i have to modify unity ml agents code in order to do that, right?

untold nebula
#

but i have to redirect the traffic from unity to python, right?
I don't know. Isn't that what you're asking..?

#

Ah, I see, so you want to intercept the observations in unity before they are sent to the unity ml-agent model. I thought you're talking about some third party stuff.

#

The easiest way would probably be to look at the C# side and see where the observations are consolidated and sent to the python side. Then hook there and redirect them wherever you want.

summer elk
untold nebula
summer elk
untold nebula
# summer elk yeah i made the thread to ask if someone knows how it works 😭

I really doubt someone ever had to deal with it, aside from unity devs.
Youll need to research on your own or hire someone to do it for you. Granted, it's not that complicated and most mid level devs should be able to figure it out.
You can ask the community specific narrow questions, but we won't do the whole job for you.

slow marsh
#

Find method ExchangeData() in Packages/com.unity.ml-agents/Runtime/Communicator/GrpcCommunicator.cs. Before you send AgentInfoProto, forward the observation buffer to your own pipe.

summer elk