# How can I get a character from a playerstate?

**URL:** <https://forums.unrealengine.com/t/how-can-i-get-a-character-from-a-playerstate/468551>\
**Category:** World Creation\
**Tags:** playerstate, unreal-engine, Physics, Collision, Blueprint, question\
**Created:** [July 23, 2020, 2:53am UTC](https://forums.unrealengine.com/t/how-can-i-get-a-character-from-a-playerstate/468551 "2020-07-23T02:53:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dellis23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dellis23](https://forums.unrealengine.com/u/dellis23)\
**Post date:** [July 23, 2020, 2:53am UTC](https://forums.unrealengine.com/t/how-can-i-get-a-character-from-a-playerstate/468551/1 "2020-07-23T02:53:35Z")

</div>

I’m using a custom PlayerState. When a PlayerState is created, I’d like to find the associated character and update its collision profile. Essentially I’m trying to set a different collision profile for each player in the game.

I’m using the first person starter content as a starter point. I’ve tried doing PlayerState-\>GetOwner-\>Cast To FirstPersonCharacter, but this fails. I see a GetPawn function [here](https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/APlayerState/index.html), but it doesn’t appear to be exposed in blueprints. Is there another way to do this? Is there a better way? I had little success getting it to work in the FirstPersonCharacter event graph, even after monkeying around with Switch Has Authority, but I may have done something wrong.

---

<div class="post-metadata">

**Author:** ![dellis23](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@dellis23](https://forums.unrealengine.com/u/dellis23)\
**Post date:** [July 23, 2020, 3:57am UTC](https://forums.unrealengine.com/t/how-can-i-get-a-character-from-a-playerstate/468551/2 "2020-07-23T03:57:33Z")

</div>

I managed to pull this off by setting it up in the GameMode after PostLogin. I had to add a delay in order to get PlayerState and Controlling pawn without getting None objects back (or perhaps it was just for PlayerState, I can’t remember).

After casting to FirstPersonCharacter and setting the collision profile, the client was unaware of the change. I also added a CollisionProfile rep notify variable onto my FirstPersonCharacter, which I set in the game mode after updating the collision profile. Then, in the notified function, I set it on the client too. Now it all seems to work.

This feels about as hacky as it can get (and I haven’t even mentioned the modulusing I’m doing to try to assign a player to a collision profile). I would still like to hear of better alternatives.

---

<div class="post-metadata">

**Author:** ![honya15](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@honya15](https://forums.unrealengine.com/u/honya15)\
**Post date:** [February 27, 2022, 4:07pm UTC](https://forums.unrealengine.com/t/how-can-i-get-a-character-from-a-playerstate/468551/3 "2022-02-27T16:07:12Z")

</div>

I know it’s late, but in case you get here from google search:  
The reason your cast is failing is because the owner of the PlayerState is a PlayerController.  
On server, you could get the character like this:  
PlayerState-\>GetOwner-\>Cast to PlayerController-\>GetCharacter

It won’t work on clients, because clients dont have other players’ PlayerController. I have no idea how to find there. I guess you could iterate all characters, and check if playerstate is the same

---

<div class="post-metadata">

**Author:** ![honya15](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@honya15](https://forums.unrealengine.com/u/honya15)\
**Post date:** [February 27, 2022, 4:17pm UTC](https://forums.unrealengine.com/t/how-can-i-get-a-character-from-a-playerstate/468551/4 "2022-02-27T16:17:30Z")

</div>

it’s even easier. There is a variable called PawnPrivate in the PlayerState, you can use that from BP (cast it to Character), or in CPP, there is a GetPawn() function.
