x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

What is a Subsystem? What should it be used for?

Unreal 4.22 introduced the new "subsystem" class, but there's not much documentation as to what it exactly is or how to use it. The release notes simply say:

Subsystems are automatically instanced classes with managed lifetimes which provide easy to use extension points without the complexity of modifying or overriding engine classes, while simultaneously getting Blueprint and Python exposure out of the box.

But that doesn't really answer my question too much. Say I want to replicate ShooterGameInstance from the ShooterGame example using subsystems. Is it as easy as just migrating all the ShooterGameInstance code into a class inheriting from UGameInstanceSubsystem? How do I "tell" the GameInstance that it's using a certain subsystem without "modifying or overriding" an engine class?

I understand how to access the subsystem from C++/Blueprints, but I don't understand when you'd want to use one or how to "point" a GameInstance/LocalPlayer/etc. at a certain subsystem, or what a subsystem is supposed to "do."

Product Version: UE 4.22
Tags:
more ▼

asked Apr 03 '19 at 05:27 AM in C++ Programming

avatar image

Jay2645
188 4 14 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Okay, poking through engine code has led to a couple discoveries:

  • Each object which can have a subsystem has a FSubsystemCollection associated with it. This FSubsystemCollection takes a template, so to use my GameInstance example, UGameInstance contains FSubsystemCollection<UGameInstanceSubsystem>.

  • When the GameInstance Init function gets called, the FSubsystemCollection looks at everything which inherits from UGameInstanceSubsystem (or whatever subsystem it's using at the time). If USubsystem->ShouldCreateSubsystem returns true, then it'll create the associated subsystem as a new object, parented to whatever the FSubsystemCollection says its parent should be ( UGameInstance, in our case). So in reality, all our subsystems get created as children of our main system.

  • The end result is that you can call UGameInstance->GetSubsystem with any valid child class of UGameInstanceSubsystem and it'll return an instance of that class. It's similar to having a component on an actor.

  • By itself, a subsystem doesn't actually do anything. Nothing gets called on it, and it doesn't override any functions. You have Initialize and Deinitialize to start and stop the subsystem, but otherwise it's an open book as to what you do with it. It just makes code clearer for non-actor objects which could benefit from a component-like interface.

more ▼

answered Apr 03 '19 at 06:20 AM

avatar image

Jay2645
188 4 14 25

avatar image 哇哈哈咩 Apr 12 '19 at 07:09 PM

Excuse me, could you describe it in more detail, or give me another example? I still don't quite understand the usage and convenience of subsystems.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question