(ASC) - Setup on Player State
this choice ideal for multiplayer games where players can switch characters or where abilities need to persist between different avatars.
Creating your PlayerState class based on RoguePlayerState.
First, let's create our PlayerState
class that derives from ARoguePlayerState
, we'll use this class to place the AbilitySystemComponent
and replicate it in its constructor.
To create this class, navigate to the top left corner of the engine and look for
Tools
, then click onNew C++ Class...

With the class creation window open, select
All Classes
and then search forARoguePlayerState
and click next.

In this image, we are creating a new class called
MyProjectNamePlayerState
, which will be derived fromARoguePlayerState
in your Unreal Engine 5 project. Here are some important points:

Make sure that the class is created as
Public
, as shown in the image. This ensures that the code is accessible from anywhere in the project.
All you need to do now is call the default constructor of the
ARoguePlayerState
class to create yourAbilitySystemComponent
derived fromURogueAbilitySystemComponent
.


Now, let's build your custom
AbilitySystemComponent
within thePlayerState
.
#include "CoreMinimal.h"
#include "Framework/RoguePlayerState.h"
#include "YourPlayerState.generated.h"
UCLASS()
class YOURPROJECT_API AYourPlayerState : public ARoguePlayerState
{
GENERATED_BODY()
public:
AYourPlayerState(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
};
In your character class, you’ll need to override the
InitAbilityActorInfo
function to specify to yourAbilitySystemComponent
who theOwnerActor
andAvatarActor
are. Let’s do that now.
#include "CoreMinimal.h"
#include "Framework/RogueCharacter.h"
#include "YourCharacter.generated.h"
UCLASS()
class AYourCharacter : public ARogueCharacter
{
GENERATED_BODY()
public:
AYourCharacter(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
// Override this function!
virtual void InitAbilityActorInfo() override;
}
Now all you have to do is create your customized
PlayerState
with theAbilitySystemComponent
and place it in yourGameMode
.


Bonus Hint: (Debug Console).
To debug and check if everything is working correctly, we will use the console panel to enter the command showdebug abilitysystem
. This command allows us to visualize the AbilitySystemComponent
on our character. Take a look


With that, you've finished setting up your AbilitySystemComponent
in PlayerState
. If you have any questions, you can add me on Discord so we can solve them.
Atualizado