Adding a UActorComponent to a APlayerState

Hello.

I want to add my custom UActorComponent to my custom APlayerState, but when I do my actor component won’t tick.
I tried to add it to my character, and it worked fine.

The player state is just a basic player state with Tick, BeginPlay and PostInitializeComponents.
It has GENERATED_UCLASS_BODY and the proper constructor, so that I could add the component on init.

Any ideas?

Maybe, PrimaryActorTick.bCanEverTick = true; in constructor will help

Doesn’t help. :confused: I really don’t know why it won’t tick.
I guess I could just create a function on the actor component that I could call each tick on my player state.

I’m fairly certain that neither PlayerStates not Actor Components tick at runtime, APlayerState inherits from AInfo I think.

Bear one thing in mind - the gamemode caches a whole bunch of playerstates at the start of a match and reuses them. You’ll have to account for that with your actor components if you’re doing multiplayer.

Also Make sure that your component also have PrimaryComponentTick.bCanEverTick = true;

But I think PlayerStates are some special actors, and should not tick by themselves. So yes, yous should update them from their actors or PlayerControllers.

You also need



PrimaryActorTick.bStartWithTickEnabled = true;


The PlayerState definitely ticks, but that may be because I have a blueprinted PlayerState.
I’ll check out bStartWithTickEnabled. :slight_smile: