# Getting a character component in the GameMode BeginPlay

**URL:** <https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123>\
**Category:** Blueprint\
**Tags:** gamemode, unreal-engine, Blueprint, question\
**Created:** [May 7, 2025, 9:03am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123 "2025-05-07T09:03:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![blAddddDe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blAddddDe](https://forums.unrealengine.com/u/blAddddDe)\
**Post date:** [May 7, 2025, 9:03am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123/1 "2025-05-07T09:03:47Z")

</div>

**HI!**  
I have a need to get a component in GameMode (mostly to create widgets at different events), but I somehow think it doesn’t look right.  
The screenshot shows what I mean:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/8/8/c884f2ece2e00245d031ae2f17cd074203926ddc.jpeg)  
How inconsiderate is it that I use GetPlayerCharacter in the GameMode BeginPlay?  
And how do you fix it?  
Thx!

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [May 7, 2025, 9:50am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123/2 "2025-05-07T09:50:14Z")

</div>

In gamemode blueprint you can override function/event OnRestartPlayer, which is called right after spawning pawn for each player/controller. It is a generic event for both players and AIs, so it passes a generic Controller as parameter. You should first cast to PlayerController to check that it is the player, then use Controller-\>GetControlledPawn to access the Pawn, then get your component from there.

---

<div class="post-metadata">

**Author:** ![blAddddDe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blAddddDe](https://forums.unrealengine.com/u/blAddddDe)\
**Post date:** [May 7, 2025, 9:54am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123/3 "2025-05-07T09:54:50Z")

</div>

Thank you! It really works. Just a little clarification on whether there will be _any overheads_ due to cast?

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [May 7, 2025, 10:06am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123/4 "2025-05-07T10:06:06Z")

</div>

In terms of memory footprint no, PlayerController is a native class and native classes are all always loaded, always.

In terms of performance, eh.. It’s just a node. If you spawn hundreds of pawns per frame then sure, it may have an impact, although it would still be negligible compared to the overhead of pawns/controllers themselves.  
Alternatively you can use Controller-\>IsPlayerController, but then you have to Branch, so that’s two nodes instead of one…  
If you don’t use AIControllers, you can probably get rid of the check altogether.

---

<div class="post-metadata">

**Author:** ![blAddddDe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blAddddDe](https://forums.unrealengine.com/u/blAddddDe)\
**Post date:** [May 7, 2025, 10:08am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123/5 "2025-05-07T10:08:03Z")

</div>

Ok, I understand, what’s the option to make a method in the gamemode interface and call it at the end of begin play character?

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [May 7, 2025, 10:09am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123/6 "2025-05-07T10:09:56Z")

</div>

GameMode always come before Character (since character is spawned by gamemode) so you can just do that in Character’s BeginPlay → Get Game Mode → call your function

---

<div class="post-metadata">

**Author:** ![blAddddDe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@blAddddDe](https://forums.unrealengine.com/u/blAddddDe)\
**Post date:** [May 7, 2025, 10:10am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123/7 "2025-05-07T10:10:31Z")

</div>

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 6, 2025, 10:11am UTC](https://forums.unrealengine.com/t/getting-a-character-component-in-the-gamemode-beginplay/2495123/8 "2025-06-06T10:11:26Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
