DefaultPawnData

DefaultPawnData

#Overview

name: DefaultPawnData

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of DefaultPawnData is to define the default configuration and attributes for player pawns in the Lyra game project. It serves as a fallback option when no specific pawn data is set for a player state.

This setting variable is primarily used in the Lyra game module, which is part of the Unreal Engine 5 project structure. It is referenced in the game mode, experience definition, and asset management systems of the Lyra game.

The value of DefaultPawnData is set in the ULyraAssetManager class, which is derived from UAssetManager. It is defined as a TSoftObjectPtr and is marked with the UPROPERTY(Config) macro, indicating that its value can be set in configuration files.

DefaultPawnData interacts with other variables and systems, particularly:

  1. It is used in the LyraExperienceDefinition class as part of the gameplay setup.
  2. The LyraGameMode class uses it to determine the appropriate pawn data for a controller.
  3. It serves as a fallback in the asset management system when no other pawn data is specified.

Developers should be aware that:

  1. This variable provides a default configuration, but it can be overridden by more specific settings in the game experience or player state.
  2. It’s a soft object pointer (TSoftObjectPtr), which means it supports asynchronous loading and can help with memory management.

Best practices when using this variable include:

  1. Ensure that a valid DefaultPawnData is always set in the configuration to avoid null pointer issues.
  2. Consider the implications of changing this default value, as it may affect the entire game if not properly managed.
  3. Use this as a baseline for pawn configuration, but implement more specific pawn data for different game modes or player types when necessary.
  4. When extending the game, always check if a more specific pawn data is available before falling back to this default.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultGame.ini:39, section: [/Script/LyraGame.LyraAssetManager]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/GameModes/LyraExperienceDefinition.h:40

Scope (from outer to inner):

file
class        class ULyraExperienceDefinition : public UPrimaryDataAsset

Source code excerpt:

	//@TODO: Make soft?
	UPROPERTY(EditDefaultsOnly, Category=Gameplay)
	TObjectPtr<const ULyraPawnData> DefaultPawnData;

	// List of actions to perform as this experience is loaded/activated/deactivated/unloaded
	UPROPERTY(EditDefaultsOnly, Instanced, Category="Actions")
	TArray<TObjectPtr<UGameFeatureAction>> Actions;

	// List of additional action sets to compose into this experience

#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/GameModes/LyraGameMode.cpp:64

Scope (from outer to inner):

file
function     const ULyraPawnData* ALyraGameMode::GetPawnDataForController

Source code excerpt:

	{
		const ULyraExperienceDefinition* Experience = ExperienceComponent->GetCurrentExperienceChecked();
		if (Experience->DefaultPawnData != nullptr)
		{
			return Experience->DefaultPawnData;
		}

		// Experience is loaded and there's still no pawn data, fall back to the default for now
		return ULyraAssetManager::Get().GetDefaultPawnData();
	}

#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/System/LyraAssetManager.cpp:34

Scope (from outer to inner):

file
function     ULyraAssetManager::ULyraAssetManager

Source code excerpt:

ULyraAssetManager::ULyraAssetManager()
{
	DefaultPawnData = nullptr;
}

ULyraAssetManager& ULyraAssetManager::Get()
{
	check(GEngine);

#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/System/LyraAssetManager.cpp:138

Scope (from outer to inner):

file
function     const ULyraPawnData* ULyraAssetManager::GetDefaultPawnData

Source code excerpt:

const ULyraPawnData* ULyraAssetManager::GetDefaultPawnData() const
{
	return GetAsset(DefaultPawnData);
}

UPrimaryDataAsset* ULyraAssetManager::LoadGameDataOfClass(TSubclassOf<UPrimaryDataAsset> DataClass, const TSoftObjectPtr<UPrimaryDataAsset>& DataClassPath, FPrimaryAssetType PrimaryAssetType)
{
	UPrimaryDataAsset* Asset = nullptr;

#Loc: <Workspace>/Projects/Lyra/Source/LyraGame/System/LyraAssetManager.h:92

Scope (from outer to inner):

file
class        class ULyraAssetManager : public UAssetManager

Source code excerpt:

	// Pawn data used when spawning player pawns if there isn't one set on the player state.
	UPROPERTY(Config)
	TSoftObjectPtr<ULyraPawnData> DefaultPawnData;

private:
	// Flushes the StartupJobs array. Processes all startup work.
	void DoAllStartupJobs();

	// Sets up the ability system