Character Selection - Lyra Starter Game

This is my quick implementation of a character selection interface using Paragon heroes. More options to be added soon.

6 Likes

Hey there @L.F.A,

Hope youā€™re doing well!

Great work so far! The audio ui interactions are 10/10. Havenā€™t gotten a chance to play around with lyra to much so not sure which parts are made by you but I definitely think this looks wonderful.

Really hope to see more of your work soon :smiley:

1 Like

Hi there, likewise, I hope you are doing well, too.
Thank you for your feedback. Lyra is fantastic, very modular, and I have very cool mods coming soon.

Best regards

Hi, there. Could you please do me a great favor? I wanted to hear from Epic team what is the best workflow for creating and saving custom settings in Lyra with Blueprints, such as character selection youā€™ve seen in that video.

The reason for my request is that looks like saving selection options in the game instance/game mode/ player controller, as pointed out by Epic years ago (AI: State of Mind | Live from HQ), is not working in Lyra with Blueprints. Perhaps C++ modification is required. I would appreciate any directions or documentation.

Here is my workflow with basic save/load logic done with blueprints only. It works if tested locally, but it is not working in a packaged game and two computers. The selection made by the host player always overwrites the clientsā€™ selection, as if all clients read the game instance from the host player, regardless the fact that the save game logic is working correctly locally.

Iā€™ve just created a question in this forum with this topic.

Thank you.

3 Likes

Iā€™ll definitely message some of the more knowledgable Unreal admins and see if I can get you the answers you need. :smiley:

3 Likes

Much appreciated. Thanks.

1 Like

Would love to know this also. Hopefully someone figures it out.

1 Like

Hey guys!

While we wait for the coolest of the Unreal people to get back to me on this, I did find this documentation that might help slightly. Let me know if it resolves your problem!

2 Likes

Hi, thanks you for this update. I believe that doc considers changing the C++ code. Iā€™ll read it through and let you know if that helps. I appreciate your help.
Best regards.

1 Like

Would also love to know this workflow, thanks for the documentation, though as it is C++ based is there any examples or tutorials that you can point to on how to add custom settings? I believe the documentation is pointing in the right direction as it does cover how settings apply to local players and I think what is happening is once the packaged game starts the host player has authority and client players save slot is not passed by the server. Iā€™m not C++ fluent and would love to see someone figure this out in blueprints.

1 Like

Iā€™ll update here if I find anything. I tried to use ColorBlind settings as example, but I couldnā€™t succeed on this. I created 2 C++ classes based on UIExtension and GameSettings, however the documentation regarding how to write the additional code to both .cpp and .h files is not clear enough to me.

3 Likes

Have you had any luck with this? Iā€™m struggling to see how we are meant to be getting GameSettings which exist only on each clientā€™s LyraLocalPlayer to the server. (At least thatā€™s my understanding).

I used to simply pass through character selection as an arg with each player as they connected to the server, but was hoping GameSettings would provide a better solution.

1 Like

Hi there, not yet. I havenā€™t had a change to go deeper on this topic. But Iā€™ve learned that Game Settings is actually a plugin itself, so Iā€™ll check it out in VS2022 later this week. Iā€™ll post here if I find anything useful.

2 Likes

C++ is an ā€˜uncharted territoryā€™ to me, but I did a quick search and here what Iā€™ve found so far. It is not final, though.

  1. In a new project, disable the MDL plugin (Omniverse) and restart. In your project content browser, show C++ classes, find LyraGameSettingRegistry, right click, and create a subclass of it, set as public and rename it as LyraGameSettingRegistry_Profile, ā€˜Profileā€™ as an example.

  2. In VS 2022, build UE5 and then your game for the first time. The step 1 will create two files: LyraGameSettingRegistry_Profile.cpp and LyraGameSettingRegistry_Profile.h. To find existing settings, search for ā€˜LyraGameSettingRegistryā€™ in the solution explorer (check ā€˜search within external itemsā€™). Youā€™ll find Gameplay (Languages), Mouse&Keyboard, PerfStats, Gamepad, Audio, and Video. Choose an existing setting, for instance, LyraGameSettingRegistry_Audio.cpp and copy part of the code, changing the existing data. In my example, I changed ā€˜Volumeā€™ and ā€˜Overall audioā€™ (scalar settings) to ā€˜Characterā€™ and ā€˜Selectionā€™. I couldnā€™t figure out the proper content for the .cpp file for my particular use case.

  3. Edit LyraGameSettingRegistry.cpp and LyraGameSettingRegistry.h to add this new setting ā€˜Profileā€™ to the existing lists, observing the proper syntax.

  4. Open W_LyraSettingScreen and add a Profile Collection to the sequence node

  5. Copy W_ColorBlindMode to a new folder Profile under Extensions folder, rename it to W_Settings_Profile, and change its icons. Add this new widget to GameSettingRegistryVisuals (Data Asset). Add a new map element ā€˜Profileā€™ and assign the new widget to the extension array

At this point, I couldnā€™t exam a proper reference for completely filling the *.cpp and the LyraGameSettingRegistry_Profile.h file for my particular case. I believe Video - Color Blind Mode is the closest setting to my use case, because it consists in a list of options to choose from a UI. I could build a list of character meshes (or actor blueprints) to be chosen from there.

Also, further analysis is needed, and many steps are missing here, because I got several errors in VS about missing references. That said, it was impossible to build the solution afterwards.

I am hoping someone is going to take it from here, itā€™s beyond my knowledge. It would be great if the devs could point us the right direction.

3 Likes

Hi, there, did you find someone who can help me with this matter? I would appreciate any inputs from the senior devs.

Best regards

2 Likes

Try this

LyraSettingsLocal.h

//  Character selection
public:
	UFUNCTION(BlueprintCallable)
	int32 GetUserCharacter();
	UFUNCTION(BlueprintCallable)
	void SetUserCharacter(int32 NewUserCharacter);

private: 
	UPROPERTY(Config)
	int32 UserCharacter;

LyraSettingsLocal.cpp

int32 ULyraSettingsLocal::GetUserCharacter()
{
	return UserCharacter;
}

void ULyraSettingsLocal::SetUserCharacter(int32 InUserCharacter)
{
	UserCharacter = InUserCharacter;
}

LyraGameInstance.h

#include "Settings/LyraSettingsLocal.h"

public:
        ULyraSettingsLocal* UserSettings;

	UFUNCTION(BlueprintCallable)
	ULyraSettingsLocal * GetUserSettings();

LyraGameInstance.cpp

#include "Settings/LyraSettingsLocal.h"

void ULyraGameInstance::Init()
{
	Super::Init();
	UserSettings = ULyraSettingsLocal::Get();
}

ULyraSettingsLocal* ULyraGameInstance::GetUserSettings()
{
	return UserSettings;
}

In the blueprint use ā€œGet Game Instanceā€ cast to LyraGameInstance then ā€œGet User Settingsā€ then ā€œGet/Set User Characterā€

I also used nodes ā€œIs Locally controlledā€ and ā€œIs Player Controlledā€ to stop the user select affecting the NPCs. Also only choose ā€œClient Componentā€ in the components list of the Lyra Experience Definition.

Result is here

2 Likes

I really appreciate that, thank you sharing this code and the link for the game on steam. Iā€™ll test it out and let you know.
Thank you so much for the help.

1 Like

Is this code already implemented in your game? I tested on Steam and it didnā€™t change the character.

It was until I updated Lyra framework and wiped out the reference to my custom version of B_PickRandomCharacter. Thanks for letting me know. Building a new version to upload now. Very much still in Betaā€¦

1 Like

Itā€™s a journey, indeed. Let me know if you need any help with testing. Good luck in your project.