-
Notifications
You must be signed in to change notification settings - Fork 70
Torch scripts don't fire after packaging with Unreal #5
Comments
I found an error in the log that is related - |
Hi @ericdanz , sorry you're having trouble packaging your game. I'm not sure that this is what's causing your problem. Here's what's executed in the embedded Lua interpreter in UETorch to startup your script:
My first guess would be that your packaged game can't find uetorch.lua or .lua. Are you sure you've set the |
Here's my LUA_PATH variable:
It includes both the scripts directory and the lua directory - but I think that would also effect the in-editor run right? I'm recompiling it now to see if I can suss out any more clues - if this doesn't work I'll make a new project as a C++ project and see if I get different results (that fixed plugin issues with some people in the Unreal forums). |
I've found that your best bet is to look at not the compile logs but the logs at runtime. You can instrument the code (both on the C++ and Lua side) in UETorch with logging/print statements to see at what point it's failing. My guess is it's not finding Lua, or not finding the correct lua source files, or something like that. You could also run in gdb and add breakpoints inside UETorch, e.g. inside TorchPluginComponent.cpp in the OnRegister function. |
I was looking at the build logs today because the packaging failed and getting this:
the solution seems to be changing MainModule in TorchPluginComponent.cpp:
and the rebuild UETorch, maybe that works for this problem too. |
@marioyc the original code in TorchPluginComponent.cpp If you just hardcode this to |
No, the Main Module field was filled, but I was still getting this at the moment of packaging. |
@ericdanz @marioyc I have reproduced the same problems you guys had. If you remove the assignment of MainModule in the constructor, it at least solves the compilation problem, but the TorchPluginComponent never fires inside the packaged game (in fact, When I was doing development a while back, I was using ScriptPlugin directly, and packaging games did work. I haven't figured it out, but some hypotheses:
|
I tried changing the Build.cs file and add UETorch to PublicDependencyModuleNames as mentioned on the first link, however after packaging the game when I try to run it I get:
The same thing happened when adding only ScriptPlugin which is where liblua,so is being added (here). Any ideas about why it is not being found? |
When you package the game, do you get the following message: Log.TraceVerbose("LUA Integration enabled: {0}", LuaInstallDirectory); If so, what does it say LuaInstallDirectory is? Is it correct, i.e. does liblua.so live there? |
I've tried setting the log level to verbose as described here in the DefaultEngine.ini file of the game but I am not seeing any of the LUA integration messages on the Cook.[number].txt log file. |
It could be that I'm not setting the log level the right way, since I also tried adding liblua.so from the game's Build.cs too, but neither of the messages is appearing in the logs. |
I was finally able to get the messages printed with Console.WriteLine and it's printing
in the UnrealBuildTools.[number].txt log which are the right paths. |
Can you try running the packaged game with LD_LIBRARY_PATH set? Like:
|
Yes, now it is working. |
Awesome! I'm happy we finally figured it out. To fix this for others, it would be best if UETorch packaged the .so into the packaged game itself and compile the game to include it in its library paths. If we can't figure it out then lets just add it to the docs and add an error message inside UETorch when it can't find liblua.so that says "set LD_LIBRARY_PATH to the folder containing liblua.so" |
I created a simple Torch script that just saved a screenshot, to test this out. It works great in the editor, but does not work at all if I package the game and run the resulting executable. I have checked the logs, it imports uetorch.lua and prints the initialization message when building.
When I run it, it looks correct, all the right (non-Torch) things are happening in the game, but the screenshots are not being saved.
I also tested this with the uetorch_example script and the basic first person project, with similar results - the scene is rendered well, but the character doesn't move forward and turn like he does in the editor.
The text was updated successfully, but these errors were encountered: