Call function before quit game

There is an extreme neccessarity of doing several things(with hardware) before exiting from application
(from VR preview) but neither “End Play Event” nor “Event Destroyed” blocks don’t do what I want.
What may be the reason?

I want call function from my C++ class after ESC pressed.
In blueprint

(I know how to call function from class, but it don’t happen )

You might try OnWorldDestroyed, but this sounds like it might be too late toi do anything with actors and blueprints. It return delegate, so use AddDynamic on it

More invasive way is to try overriding PreExit in UEngine

To change UEngine class that will be used you need to set value in DefaultEngine.ini in project directory “Config” (add them if they are missing) you can’t set those in editor you need to do that manually:

[/Script/Engine.Engine]
GameEngine=/Script/Engine.GameEngine
EditorEngine=/Script/UnrealEd.EditorEngine
UnrealEdEngine=/Script/UnrealEd.UnrealEdEngine

And yes you probably will need to override for each of those classes, they all UEngine, one is for game and 2 is for editor. Thie format is: /Script/ModuleName.ClassNameWithoutUprefix, module is name of dll that class is in, by default it is same as project name

If either of those don’t work for you try looking around in those 2 classes, they both impotent in world management

UWorld manages actors in world (if UWorld get deleted all actors associated with goes with it), UEngine is a core engine class, it manages worlds and all main functions of engine and you can actully override it like AGameMode as i said above :slight_smile: