Introduction
Mover is modular and data-driven. Each movement mode can contain relevant settings that are only used for that mode and exist within the movement mode instance itself.
However, in general, multiple movement modes may also share some settings.
This section mainly discusses the relationship between movement modes and shared settings, as well as the principles for creating and using shared settings.
Configuring Shared Settings
Each movement mode can specify the required type of shared settings in itsSharedSettingsClassesfield, and when you finish editing theMovementModes, theMoverComponenton theSharedSettingsarray will automatically refresh based on the configuration ofMovementModes.
If there exists a certain type of setting that is not used by any movement mode, it will be automatically removed from the array.
You can check theUMoverComponent::RefreshSharedSettings() to understand the specific logic.
Using Shared Settings
Each movement mode can implement OnRegistered and OnUnregistered, and at this time, it can obtain the corresponding shared settings through the MoverComponent and cache them for use in other logic under that mode.
1 TObjectPtr<const UCommonLegacyMovementSettings> CommonLegacySettings;
1void UWalkingMode::OnRegistered(const FName ModeName)2{3 Super::OnRegistered(ModeName);45 CommonLegacySettings = GetMoverComponent()->FindSharedSettings<UCommonLegacyMovementSettings>();6 ensureMsgf(CommonLegacySettings, TEXT("Failed to find instance of CommonLegacyMovementSettings on %s. Movement may not function properly."), *GetPathNameSafe(this));7}89void UWalkingMode::OnUnregistered()10{11 CommonLegacySettings = nullptr;1213 Super::OnUnregistered();14}
