How to make the blueprint subclass that inherits from localplayersubsystem usable after packaging?

Hello everyone, I have created a class that inherits from localplayerSubsystem and added an initialization event to its blueprint subclass. But the initialization event is only triggered in PIE mode and will not be triggered after packaging. Is there any way to solve it? I plan to create and manage the UI for local game players :joy:

There is no good solution for any of the subsystems to have blueprint subclasses. They’re just generally unsupported by default. If you want to subclass subsystems you have to move to C++, even if that’s just to make a shim that spawns an actor during subsystem init so that you can do the rest of the logic from blueprint.

You’d probably find that if you started up your game in PIE without having opened your subsystem blueprint in that Editor session, the initialization function wouldn’t work in PIE either.

My final solution was to first implement Settings and modify the Module to set LocalPlayerSubsystem in the project settings. Load and register all declared blueprint types of LocalPlayerSubsystem through him. Then generate LocalPlayerSubsystems through a worldsubsystem. This can also be done after packaging.

Enable subsystem in project settings before packaging :grinning_face:

initialize firing only in PIE has a specific cause: your blueprint subclass is game content, and the subsystem registration scan that finds blueprint subsystem classes runs through configured directories. in PIE everything in the project is loaded anyway, in a packaged build only assets referenced from maps or explicitly configured make it in.

fix checklist:

  1. project settings, packaging, additional asset directories to cook: add the folder your subsystem blueprint lives in, so it cooks at all.
    1. project settings, packaging, blueprint class references: add the class explicitly if the blueprint still is not seen. this list forces class references into the cooked build even when nothing else references them.
    1. if you shipped the subsystem inside a plugin, make sure the plugin is enabled for the target (it must be listed in the uproject plugins array with enabled true, not just editor enabled), and plugin content cooking is on in packaging settings.
    1. the registration itself: blueprint subsystem classes are discovered when their packages load, so once steps 1-2 are right the engine creates the instance on local player creation, and initialize fires in packaged builds exactly like PIE.
      one more classic trap hiding under this symptom: overriding initialize in blueprint requires the initialize event node from the subsystem palette, not a custom event named initialize. if you defined a custom event, it never gets called by the engine, and PIE success would have been coincidence of something else calling it. check that your override is the actual engine virtual.

also worth structuring around: initialize is very early, world and players may not exist yet. anything needing the local player or world belongs in a later phase (on world beginplay via a world subsystem, or deferred from your game instance), not inside the local player subsystem initialize.