Hi, there are commands for simulation but I did not find for PIE
unreal.LevelEditorSubsystem().editor_play_simulate()
or
unreal.EditorLevelLibrary().editor_play_simulate()
but no command unreal.LevelEditorSubsystem().editor_play()
Hey there @jenios3! Welcome to the community! Judging by the documentation on the API and that the python commands also come from the Blutility nodes/code, it doesn’t seem like there’s a python based way to launch PIE. I can’t find anything exposed for Blutilities either so it’s possible it may need a source edit. Are you working from the launcher version?
Yes, in 5.0.3
But I don’t know C++ well.
Theoretically, I understand that you need to create your own function, which should work as a play button and which can be called in python.
What files need to be changed and with what code?
- 4 Ways To Level Up Your Python Code. Avoid unnecessary loops, access dictionary items more effectively, and more
- Replace range(len()) With enumerate()
- Stop Using Square Brackets To Get Dictionary Items — Use .get()
- Simplify Iterating Over Multiple Lists With Zip()
- Use f-strings To Easily Print to the Console.
I need to understand how to run PIE from python
I’ll have to dig into the source a bit to verify if it would be a simple function call. My bets are it’s going to be a little more involved since there’s no base command for it as of yet.
I was able to find something similar but I couldn’t run this code
FLevelEditorModule& LevelEditorModule = FModuleManager::Get().GetModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
TSharedPtr<class ILevelViewport> ActiveLevelViewport = LevelEditorModule.GetFirstActiveViewport();
GUnrealEd->RequestPlaySession(false, ActiveLevelViewport, bSimulateInEditor, NULL, NULL, -1, false);
Apparently something has changed in 8 years or I’m doing something wrong
Hrm looks like it hasn’t changed much. Looking at the docs the params seem to have changed a bit. Are there any errors on the output? Might need to write it a bit more custom looking at these docs.
I’m looking to do something similar and wondered if you found a solution. Ideally I want to do this in Python.
I still haven’t found a way to run PIE
@jenios3 @KidAWS I am also trying to play the current level through the Unreal Python API but can’t seem to find a solution. Have any of you found a way to do it yet?
following works for my case. I execute python script which contains following:
import pyautogui
import time
time.sleep(1)
pyautogui.keyDown(‘alt’)
pyautogui.press(‘p’)
pyautogui.keyUp(‘alt’)
You need to install pyautogui library.
However, this only works if editor is open and it does simple keypress, but may not be useful for other scenarios.
unreal.EditorLevelLibrary.editor_play_simulate()
unreal.EditorLevelLibrary.editor_end_play()
this is to simulate, not to play in editor or in new window PIE
level_editor_subsystem.editor_request_begin_play()
dont thank me