I’m working on a chess game that can communicate with a process that acts as a server and a chess engine. Being relatively new to Godot, I needed confirmation on two things:
Does OS.CreateProcess() require the executable file to exist outside the exported game? Or, can I use the “res//…” path somehow?
Assuming I use OS.CreateProcess() with an apk made by Godot, can I pass arguments and use OS.GetCmdlineArgs() in the apk to get them?
I see. So I must include any binary executable file in the export filters when exporting to Android. I will test to see If I can create a process using ProjectSettings.globalize_path(“res://”) path.
And do you know anything about my second question?
It didn’t work. Both when I used
gamePath = OS.GetExecutablePath().GetBaseDir();
executable = gamePath.PathJoin(“Bin/UdpServer/ServerTest.exe”);
OS.CreateProcess(executable , System.Array.Empty(), true);
Or
gamePath = ProjectSettings.GlobalizePath(“res://”);
executable = gamePath + “Bin/UdpServer/ServerTest.exe”;
OS.CreateProcess(executable , System.Array.Empty(), true);
I’m not sure .exe can run on Android? Is that binary compiled in the architecture of the target os?
Also the difference between create process and execute. One will create a new process the other a child thread. IDK if Android app permissions have specific applications here?
That line of code listed in the error on os_windows_cpp:851 is making a windows function call CreateProcessW. So it seems like windows didn’t like the parameters you provided, or there was another issue.
If you execute the parameters on the command line yourself, what happens?
Try using the second example:
“C:\Users\<?>\Desktop\UdpServer\ServerTest.exe”
Your username seems like it isn’t utf compatible with Godot?
You can’t use a res:// path to launch a binary with OS.create_process(). In most platforms the path is read-only when exported or it’s a pck file. You’ll need to extract the executable to a path in the system.
Godot Engine provides the OS class for various platform-specific functionalities, including process creation. However, Godot’s OS class does not directly expose methods for redirecting a process’s standard input, output, or error streams.
If you need to interact with the standard input of a process in Godot, you may need to consider alternative approaches, such as using custom inter-process communication (IPC) mechanisms or modifying the source code of the external process if you have control over it.