# Player Controller – Get Controlled Pawn – Client delayed

**URL:** <https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212>\
**Category:** Character & Animation\
**Tags:** event-begin-play, unreal-engine, question, Blueprint\
**Created:** [March 4, 2015, 7:57pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212 "2015-03-04T19:57:12Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 4, 2015, 7:57pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/1 "2015-03-04T19:57:12Z")

</div>

As I am new to UE4 engine, I ran across a problem casting to players controlled pawn. At first, I was completely puzzled why a component reference variable I was using was not being set. Because this worked fine on server and not on a client, I was certain this was a replication issue (I am still sorting that logic out).

After many trials, I found that issue was not replication but that Event Begin Play was being fired on client before character object was accessible to its controller (client side). To figure this out, I did a quick test controller and linked its Event Begin Play to a character cast (getting self-controlled pawn); it failed every time. Next, I added a delay function and had cast re-fire every tick for up to 5 delta seconds and sure enough, after 1 failed attempt, it casted perfectly.

 ![32347-controler_test.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/5/0f5984049c36224119ba3c166978f022bedf647b.jpeg)

_LogBlueprintUserMessages: **Server** : Event Begin Play: Received valid character cast after (0.0) delta seconds! LogBlueprintUserMessages: **Client 1** : Event Begin Play: Received valid character cast after (0.147438) delta seconds!_

It likely makes sense that server fired event on client after server had spawned and linked that controller’s character with no regard to client’s pawn state. Is this a correct assumption?

Ultimately, my questions are:

1. is this working as intended and I am just misusing it?

2. If this is a “bad” place to modify controller pawns, where is best place?

I would like to set up multiplayer input controls and functions to be casted/executed on a player’s character without having to duplicate them on every character (movement, camera controls, etc.). I chose to try controller as it would remain same throughout but character may change. Given this sync _concern_, I am a bit lost.

Thanks!

**Edit:**

I have done some more testing. further I go down this rabbit hole more confused I get! I added some logic for controller to tell me via string print exactly which controller each message was referring too and exactly how many times it tried. I also set it to run two clients on a dedicated server in same instance and this is what it had to say:

 ![32354-controller_test2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/3/c/a3c8ef3f799a54cdb6be01a83008506b6bba5b0c.jpeg)

\*LogBlueprintUserMessages: **Server** : TestController1 Failed cast attempt 1.

LogBlueprintUserMessages: **Server** : TestController1 Event Begin Play: Received valid character cast after (0.0) delta seconds!

LogBlueprintUserMessages: **Server** : TestController2 Failed cast attempt 1.

LogBlueprintUserMessages: **Server** : TestController2 Event Begin Play: Received valid character cast after (0.0) delta seconds!

LogBlueprintUserMessages: **Client 1** : TestController3 Failed cast attempt 1.

LogBlueprintUserMessages: **Client 1** : TestController3 Event Begin Play: Received valid character cast after (0.283715) delta seconds!

LogBlueprintUserMessages: **Client 2** : TestController4 Failed cast attempt 1.

LogBlueprintUserMessages: **Client 2** : TestController4 Event Begin Play: Received valid character cast after (0.283715) delta seconds!\*

I am very puzzled as to why TestController1 and TestController2 are printing out failed cast attempt and then a success attempt at 0.0 which would mean it never hit a cast failure?… _facepalm_. only thing I can figure is that this has to be some type of instantiation order in engine (i.e Controller → Pawn) that is causing desync; but that begs to question why server is innately looping cast but client does not.

---

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 5, 2015, 4:33pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/2 "2015-03-05T16:33:48Z")

</div>

I’m still interested in anyones input, even if not a solution.

---

<div class="post-metadata">

**Author:** ![Deventico\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deventico\_1](https://forums.unrealengine.com/u/Deventico_1)\
**Post date:** [March 5, 2015, 5:59pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/3 "2015-03-05T17:59:38Z")

</div>

It’s annoying in my opinion. I solve it that way:

 ![32514-doonce.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/c/8/6c8a520b926745874520ec7789b2690c0e942bb0.png)

Probably not best solution, but it works.

---

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 5, 2015, 6:03pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/4 "2015-03-05T18:03:06Z")

</div>

Yeah, with no breakout though I would be concerned about creating an infinite loop. I’m really curious about logic behind way it is working. Moreover, if it is supposed to work that way, if it is just an innate behavior of system, or if it is a bug in general.

Thanks for reply!

---

<div class="post-metadata">

**Author:** ![Deventico\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deventico\_1](https://forums.unrealengine.com/u/Deventico_1)\
**Post date:** [March 5, 2015, 6:28pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/5 "2015-03-05T18:28:16Z")

</div>

It’s not an infinite loop. After you enter reset, execution stops as far as I know.

But yeah, it’s a nuisance. That’s why I subscribed to question, maybe someone finds a better way / explanation for current situation 🙂

---

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 5, 2015, 7:06pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/6 "2015-03-05T19:06:04Z")

</div>

By infinite I meant that if controller, for any reason, never receives a valid pawn attachment it would loop infinitely, or at least potential to run every tick for a very long time. This could be solved by putting an incremental check or time-out on IsNotValid Exec. And I agree, I’m very interested in an explanation. I hope that one of these C++ gurus know code well enough; I do not.

---

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 7, 2015, 1:04am UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/7 "2015-03-07T01:04:30Z")

</div>

I moved this question to C++ section as this is likely where answer is.

---

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 8, 2015, 9:27pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/8 "2015-03-08T21:27:24Z")

</div>

Bumping for thoughts/solutions.

---

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 12, 2015, 5:17pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/9 "2015-03-12T17:17:17Z")

</div>

Still bumping - If this is a bug I would be happy to move it. If it is not, then I would like to know what proper procedure is. Thanks!

---

<div class="post-metadata">

**Author:** ![Deventico\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deventico\_1](https://forums.unrealengine.com/u/Deventico_1)\
**Post date:** [March 12, 2015, 6:51pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/10 "2015-03-12T18:51:40Z")

</div>

I’d like to know this as well.

Especially since relationship between player controller and player pawn is not some obscure unkown feature you have to deal with, but is basically used by _everyone_.

---

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 14, 2015, 4:18pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/11 "2015-03-14T16:18:05Z")

</div>

Bumping…

---

<div class="post-metadata">

**Author:** ![Purecyn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Purecyn](https://forums.unrealengine.com/u/Purecyn)\
**Post date:** [March 18, 2015, 4:24pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/12 "2015-03-18T16:24:58Z")

</div>

Perhaps I should move this to bug reports.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_33800a51](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_33800a51](https://forums.unrealengine.com/u/anonymous_user_33800a51)\
**Post date:** [March 19, 2015, 2:28am UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/13 "2015-03-19T02:28:43Z")

</div>

Hi Purecyn,

This is caused, as you suspect, by instantiation order. You were essentially casting to something that didn’t exist yet, so it failed until you put delay node in there. A safer way to handle this is to take advantage of Event Post Login in GameMode. This event fires after a player has successfully logged in and has been assigned a player controller (which it handily gives you as a node). From here, you can then cast to any functions in other Blueprints that you need to wait for clients to be logged in.

Take a look at GameMode BP in Multiplayer Shootout project, available in Learn tab of Launcher, for an excellent example of how this works.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Bitcoin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bitcoin](https://forums.unrealengine.com/u/Bitcoin)\
**Post date:** [October 9, 2015, 11:17am UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/14 "2015-10-09T11:17:20Z")

</div>

this helped a lot!

---

<div class="post-metadata">

**Author:** ![TechLord](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/techlord/32/1040563_2.png) [@TechLord](https://forums.unrealengine.com/u/TechLord)\
**Post date:** [March 6, 2017, 4:21pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/15 "2017-03-06T16:21:00Z")

</div>

I struggled with this one for days, until find this thread. I was weary of using a Event Tick so, created a Custom Event and used a SetTimerbyFunctionName BP Node.! Thank you.

 ![128840-delayedcontrolledpawn.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/6/0a6e3d7b33d2780b1a6a11e40118fe1dd3bd52b2.png)

---

<div class="post-metadata">

**Author:** ![Two-faced](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Two-faced](https://forums.unrealengine.com/u/Two-faced)\
**Post date:** [April 20, 2017, 9:50pm UTC](https://forums.unrealengine.com/t/player-controller-get-controlled-pawn-client-delayed/309212/16 "2017-04-20T21:50:26Z")

</div>

A little bit more elegant

 ![134961-2017-04-21_04-46-55.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/8/9/489b16cf710201a371159354af4254118c8b228d.png)
