# The elusive "getgameinstance()" method

**URL:** <https://forums.unrealengine.com/t/the-elusive-getgameinstance-method/428956>\
**Category:** C++\
**Tags:** gameinstance, unreal-engine, UE4, CPP, question\
**Created:** [July 8, 2018, 6:20pm UTC](https://forums.unrealengine.com/t/the-elusive-getgameinstance-method/428956 "2018-07-08T18:20:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_fe28a43b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fe28a43b](https://forums.unrealengine.com/u/anonymous_user_fe28a43b)\
**Post date:** [July 8, 2018, 6:20pm UTC](https://forums.unrealengine.com/t/the-elusive-getgameinstance-method/428956/1 "2018-07-08T18:20:51Z")

</div>

Struggling to get this object.

I have followed the following here:

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

and Visual studio tells me here:

UMyGameInstance\* GI = Cast(GetGameInstance());

identifier “GetGameInstance” is undefined

Class is defined as…  
class UMyGameInstance : public UGameInstance

So how can I get this object?  
I keep reading about three different includes for this and so on.  
I have tried every method I can find but always end up with the same exact failure.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_fe28a43b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fe28a43b](https://forums.unrealengine.com/u/anonymous_user_fe28a43b)\
**Post date:** [July 8, 2018, 6:41pm UTC](https://forums.unrealengine.com/t/the-elusive-getgameinstance-method/428956/2 "2018-07-08T18:41:10Z")

</div>

Nevermind.  
#include “Engine/World.h”  
and  
GetWorld()-\>GetGameInstance()

is my friend. Sorry for the noise.
