# Pawn PlayerState reference on client is sometimes NULL

**URL:** <https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481>\
**Category:** Character & Animation\
**Tags:** playerstate, client, unreal-engine, bug-report, question\
**Created:** [July 16, 2015, 11:39am UTC](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481 "2015-07-16T11:39:10Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![CarloMaker](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CarloMaker](https://forums.unrealengine.com/u/CarloMaker)\
**Post date:** [July 16, 2018, 8:23am UTC](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481/21 "2018-07-16T08:23:24Z")

</div>

Confirm . So do i .

---

<div class="post-metadata">

**Author:** ![Caviarail](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Caviarail](https://forums.unrealengine.com/u/Caviarail)\
**Post date:** [August 13, 2019, 10:03pm UTC](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481/22 "2019-08-13T22:03:54Z")

</div>

Confirmed, being in 4.21.0. Pretty reproducable, using PlayerState right in OnRep\_PlayerState() itself. So I decided to handle every PlayerState-related thing on Server from there on, which works and throwing a log there to remind me that “sometimes” PlayerState is invalid on Client.

---

<div class="post-metadata">

**Author:** ![iamisandisnt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iamisandisnt](https://forums.unrealengine.com/u/iamisandisnt)\
**Post date:** [November 20, 2020, 4:26pm UTC](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481/23 "2020-11-20T16:26:25Z")

</div>

Been having this issue since forever. Glad to see some input on it, but I’m not using a spectator class. One other thing I noticed is that invalid client won’t use Player Spawn points. Instead, they just float at 0,0,0 where I’ve built a holding chamber for me to recognize problem when bug-testing as a user.

---

<div class="post-metadata">

**Author:** ![ysh11o](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ysh11o](https://forums.unrealengine.com/u/ysh11o)\
**Post date:** [April 6, 2023, 10:56am UTC](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481/24 "2023-04-06T10:56:54Z")

</div>

Confirmed In 4.27

---

<div class="post-metadata">

**Author:** ![eatmorepies](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@eatmorepies](https://forums.unrealengine.com/u/eatmorepies)\
**Post date:** [December 22, 2023, 5:58am UTC](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481/25 "2023-12-22T05:58:50Z")

</div>

The behavior of the Player State being set to null on calling `Unpossess()` on the controller is still present as of 5.3.2.  
Namely, `AController::UnPossess()` is calling `OnUnPossess()`:

```auto
void AController::UnPossess()
{
	APawn* CurrentPawn = GetPawn();

	if (CurrentPawn == nullptr)
	{
		return;
	}

	OnUnPossess();
//...

```

`AController::OnUnPossess()` is calling `Pawn->UnPossessed()`, which is doing the setting of the player state to null:

```auto
void APawn::UnPossessed()
{
	AController* const OldController = Controller;

	ForceNetUpdate();

	SetPlayerState(nullptr);
	SetOwner(nullptr);
	Controller = nullptr;
//...

```

Design-wise, why do calls to `AController::UnPossess()` (and `AController::Possess()`, in fact) modify the player state at all? Or is this really a long-existent bug?

---

<div class="post-metadata">

**Author:** ![pawciut](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pawciut/32/476660_2.png) [@pawciut](https://forums.unrealengine.com/u/pawciut)\
**Post date:** [April 19, 2024, 1:50pm UTC](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481/26 "2024-04-19T13:50:40Z")

</div>

confirmed on 4.27  
on client local PlayerControler is there (for Player2), gamestate has one element in PlayerArray (which is PlayerState for Player1), and PlayerState for Player2 is null and its not present in PlayerArray

---

<div class="post-metadata">

**Author:** ![pawciut](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/pawciut/32/476660_2.png) [@pawciut](https://forums.unrealengine.com/u/pawciut)\
**Post date:** [April 19, 2024, 2:17pm UTC](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481/27 "2024-04-19T14:17:09Z")

</div>

> [@eatmorepies](#):
>
> `UnPossess`

What fixed it for me was that I forgot to call  
`Super::UnPossessed();`  
in my custom Pawn class when I override UnPossessed()

Or not, maybe it was just a lucky run, now again this happened

[Previous page](https://forums.unrealengine.com/t/pawn-playerstate-reference-on-client-is-sometimes-null/325481.md?page=1)
