How can I Transfer Bot player data in multiplayer games ( Using PlayerState in AiCcntrollers )

Hi friends ,
We have been developing a multiplayer game ,
now we came a cross an issue after adding bot to our game which is saving Bots data (data or info that needed by other players like number of kills , deaths and more)

Now as you may know UE AAIController does not have a AplayerState built-in with it .

so my question is How can we transfer data from Bots to all other players ?
or is there anyway to add APlayerState to AAIController
or can we use AController to control bots ?

I appreciate any help , thank you so much .

Yes you can simply set bWantsPlayerState = true in your AI controller class and it will spawn its own default playerstate just like regular players.

Be aware though that when bot controllers have a playerstate, they don’t destroy themselves automatically when their pawn dies. You might want to alter your gamemode logic to handle respawning bots (just like players) rather than recreating them. If they do not need to respawn, you might want to destroy the controller when they die.

1 Like

Chatouille thank you I heard about that before but did not know how it works .

btw do you know how can I force my Bots to Spawn a User Created APlayerState class ?

thank you so much.

Bots will use whatever PlayerState class you specify as the default in your GameMode class (or in the WorldSettings overrides).

1 Like

ok , thank you so much .