# Calling function in custom game state causes crash

**URL:** <https://forums.unrealengine.com/t/calling-function-in-custom-game-state-causes-crash/285088>\
**Category:** C++\
**Tags:** game-state, unreal-engine, Blueprint, question\
**Created:** [June 5, 2014, 3:34pm UTC](https://forums.unrealengine.com/t/calling-function-in-custom-game-state-causes-crash/285088 "2014-06-05T15:34:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ZoltanE](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZoltanE](https://forums.unrealengine.com/u/ZoltanE)\
**Post date:** [June 5, 2014, 3:34pm UTC](https://forums.unrealengine.com/t/calling-function-in-custom-game-state-causes-crash/285088/1 "2014-06-05T15:34:26Z")

</div>

I have a custom weapon which on creation should call a function in the custom  
game state to “register itself”, so the game state has it in a variable for quick  
reference. After setting this up everything compiles fine. When starting a PIE  
session, the editor crashes. From then on if anything attempts to touch any of  
the assets involved, the editor crashes:

- Opening a map with the custom game state referenced.
- Opening the weapon class to edit.
- Opening any blueprint interface used in either of them.

Other things to note:

- I’m on 4.1.1 because even a working version crashes 4.2 on startup (seems to be an unrelated problem).

- Everything in the project is made with Blueprints.

- What matters is making the call. The class it’s called from or the data passed seems to be irrelevant.

- The log is useless:

EDIT: More clues:

- The GetGameState seems to return a valid object. The PlayerArray is 1 as expected but the GetElapsedTime is always 0 regardless when I query it.
- The GameState’s function can be called from the player controller and the game mode. Tried from several actor derived classes, crashed every time.
- I forgot to mention this because it’s been happening since forever: PIE (along with the editor) crashes every time after I edit and successfully compile the default pawn, controller or game mode. Nothing permanently broken, after restart I carry on where I left off. The log ends the same way as above.

EDIT 2: Even when the editor crashes (like opening a map which refers to any of the now radioactive assets or starting PIE) a standalone, uncooked game works. Unusually low frame rates but everything functions as expected.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_b9532c9a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_b9532c9a](https://forums.unrealengine.com/u/anonymous_user_b9532c9a)\
**Post date:** [July 16, 2014, 6:29pm UTC](https://forums.unrealengine.com/t/calling-function-in-custom-game-state-causes-crash/285088/2 "2014-07-16T18:29:56Z")

</div>

Hi ,

I apologize for the delayed response. Is this still occurring for you? If so can you post your crashlogs, dxdiag, and callstack so we can have a look? Thank you!

---

<div class="post-metadata">

**Author:** ![ZoltanE](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ZoltanE](https://forums.unrealengine.com/u/ZoltanE)\
**Post date:** [July 17, 2014, 3:29pm UTC](https://forums.unrealengine.com/t/calling-function-in-custom-game-state-causes-crash/285088/3 "2014-07-17T15:29:13Z")

</div>

I removed the hackaround in 4.3 and everything seems to be working as expected.
