# Access Game Instance from Object class?

**URL:** <https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123>\
**Category:** Blueprint\
**Tags:** unreal-engine, Blueprint, question\
**Created:** [August 21, 2023, 7:36pm UTC](https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123 "2023-08-21T19:36:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![eobet](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eobet/32/465239_2.png) [@eobet](https://forums.unrealengine.com/u/eobet)\
**Post date:** [August 21, 2023, 7:36pm UTC](https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123/1 "2023-08-21T19:36:15Z")

</div>

I get that I can’t access the Game Instance from a Primary Data Asset (though it would be nice), but why can’t I access it from a standard Object class?

Quite a few tutorials say that it’s best practice to store commonly used variables and general game related things in the Game Instance, so why can I only make use of that in Actors?

I want to make a data class which has some sense of context, yet I’m locked out of much of my game’s data… having to initialize the class when used as a variable with the Game Instance feels yucky. Anyone have a cleaner workaround?

---

<div class="post-metadata">

**Author:** ![Shmoopy1701](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shmoopy1701/32/1194536_2.png) [@Shmoopy1701](https://forums.unrealengine.com/u/Shmoopy1701)\
**Post date:** [August 21, 2023, 7:46pm UTC](https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123/2 "2023-08-21T19:46:28Z")

</div>

Common way to get GameInstance anywhere in C++ is UGameplayStatics::GetGameInstance(). There’s probably a blueprint for it as well.

[UGameplayStatics::GetGameInstance | Unreal Engine Documentation](https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/Kismet/UGameplayStatics/GetGameInstance/)

---

<div class="post-metadata">

**Author:** ![eobet](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eobet/32/465239_2.png) [@eobet](https://forums.unrealengine.com/u/eobet)\
**Post date:** [August 22, 2023, 8:06pm UTC](https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123/3 "2023-08-22T20:06:38Z")

</div>

Thanks, but I asked in Blueprints. 🙂

And sigh, of course there’s a C++ way. Just more proof that Epic doesn’t care about people who want to use Blueprints. 😩

---

<div class="post-metadata">

**Author:** ![Shmoopy1701](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shmoopy1701/32/1194536_2.png) [@Shmoopy1701](https://forums.unrealengine.com/u/Shmoopy1701)\
**Post date:** [August 25, 2023, 4:04am UTC](https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123/4 "2023-08-25T04:04:05Z")

</div>

Is this it?

[Get Game Instance | Unreal Engine Documentation](https://docs.unrealengine.com/4.27/en-US/BlueprintAPI/Game/GetGameInstance/)

---

<div class="post-metadata">

**Author:** ![UnrealEverything](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnrealEverything](https://forums.unrealengine.com/u/UnrealEverything)\
**Post date:** [August 25, 2023, 5:40am UTC](https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123/5 "2023-08-25T05:40:20Z")

</div>

Some nodes (such as `GetGameInstance`) need a valid `WorldContext` in order to do their task. And so if you try to call this from an object that does not provide this `WorldContext` (needs to override `GetWorld` in C++) blueprints prevent you from calling these functions.

The two solutions from here [Is there a way to use Blueprint Function Libraries or an equivelent feature for non-actor blueprints? - #4 by UnrealEverything](https://forums.unrealengine.com/t/is-there-a-way-to-use-blueprint-function-libraries-or-an-equivelent-feature-for-non-actor-blueprints/878180/4) should work for you as well, unfortunately they both require some C++ code.

---

<div class="post-metadata">

**Author:** ![eobet](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/eobet/32/465239_2.png) [@eobet](https://forums.unrealengine.com/u/eobet)\
**Post date:** [August 26, 2023, 4:18pm UTC](https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123/6 "2023-08-26T16:18:00Z")

</div>

> [@Shmoopy1701](#):
>
> Is this it?

Unfortunately doesn’t work in a child class of Object.

> [@UnrealEverything](#):
>
> unfortunately they both require some C++ code.

Thanks for the tip, but a few years ago when I tried C++ I was prevented from launching my project with only a generic “Try rebuilding from source manually” message and I swore I’d never be locked out like that again, and since I stopped using C++ I never have.

The workarounds are truly a struggle, though…

---

<div class="post-metadata">

**Author:** ![ajinkya\_x](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/ajinkya_x/32/1023283_2.png) [@ajinkya\_x](https://forums.unrealengine.com/u/ajinkya_x)\
**Post date:** [May 3, 2025, 9:02am UTC](https://forums.unrealengine.com/t/access-game-instance-from-object-class/1268123/7 "2025-05-03T09:02:16Z")

</div>

worked for me 🙂

```auto
void UDialogueComponent::InitiateDialogue()
{
	UE_LOG(LogTemp, Log, TEXT("DialogueComponent on %s attempting to initiate dialogue (placeholder)"), *GetOwner()->GetName());

	UDialogueManager* DialogueManager = UGameplayStatics::GetGameInstance(this)->GetSubsystem<UDialogueManager>();
	if (DialogueManager)
	{
		 // Need to determine the other participant
		 // DialogueManager->StartDialogue(GetOwner(), OtherParticipant);
	}
}

```
