# Need help for making Singleton style UObject and other problems.

**URL:** <https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [April 11, 2016, 9:30am UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784 "2016-04-11T09:30:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 11, 2016, 9:30am UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/1 "2016-04-11T09:30:22Z")

</div>

Hello. I used to program in Cocos2D and Unity. I am developing a game in Unreal as new approach.

My project is 2D Chrono Trigger-ish (or Final Fantasy) with using a lot of Uflipbook.

The problems that I encounter, bugged me 2-3 days now. These question is very beginner-ish but I really need your help. Please…

1.I created C++ class inherited from UObject, and how do I create instance from it? I need to use it like Singleton.

I tried an actor object to “Construct Object” my singleton, and I cannot check whether it is instanced really or not.

I also tried Rama’s global access code

> **[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...

something is not enough to do what i want.

I need to use it from my Singleton during runtime too. Using value (or reference) from data in my Singleton…

2.Inside my UObject based Singleton, there are manager classes, which inherited from UObject. one of them is called Animation Manager,

which I used it to store a lot of Flipbooks by TMap (by accessing through UFUNCTION). The problem is… when my player actor use this Animation Manager’s flipbook

through my Singleton, it crashes my Unreal Engine, and I have to delete Binary folder in order to open Unreal Engine again.

Is there better way to implement sub manager class? and how to use it?

3.When I play the scene, GameMode1, GameNetworkManager1, and a lot of stuff pops out. I don’t really need them except camera, because as I explained above,

it is Chrono Trigger Style game, not FPS shooter. How do I disable them?

I am aware that I am asking a lot. I have been researching the Unreal Engine by myself and googling. those actions is not enough to get what I want.

Pretty Please. 😛

---

<div class="post-metadata">

**Author:** ![SolidGasStudios](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/solidgasstudios/32/1194575_2.png) [@SolidGasStudios](https://forums.unrealengine.com/u/SolidGasStudios)\
**Post date:** [April 11, 2016, 3:37pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/2 "2016-04-11T15:37:10Z")

</div>

I use NewObject\<Type\>() to construct UObjects.  
As for a singleton, I use my GameMode to store it and call through a static library.

There might be a better way, but for now this works.

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 11, 2016, 5:18pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/3 "2016-04-11T17:18:42Z")

</div>

> [@Telimaktar;510661](#):
>
> I use NewObject\<Type\>() to construct UObjects.  
> As for a singleton, I use my GameMode to store it and call through a static library.
> 
> There might be a better way, but for now this works.

New Object \<Type\>() UObject, GaneMode, that sounds interesting. But if I construct UObject, is it possible to check it by any mean necessary during run time?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_689e935a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_689e935a](https://forums.unrealengine.com/u/anonymous_user_689e935a)\
**Post date:** [April 11, 2016, 6:53pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/4 "2016-04-11T18:53:42Z")

</div>

In Project Settings \> Engine \> General Settings \> Game Singleton Class you can actually set your own class derived from UObject. Maybe that would help?

> **[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...

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 12, 2016, 12:12am UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/5 "2016-04-12T00:12:54Z")

</div>

> [@Gigantoad;510787](#):
>
> In Project Settings \> Engine \> General Settings \> Game Singleton Class you can actually set your own class derived from UObject. Maybe that would help?
> 
> [A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums](https://wiki.unrealengine.com/Global_Data_Access,_Data_Storage_Class_Accessible_From_Any_CPP_or_BP_Class_During_Runtime)

I already did it too… but where can i check it during runtime though? anyway thank you for answer 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_689e935a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_689e935a](https://forums.unrealengine.com/u/anonymous_user_689e935a)\
**Post date:** [April 12, 2016, 12:59am UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/6 "2016-04-12T00:59:56Z")

</div>

> [@Marjane;510945](#):
>
> I already did it too… but where can i check it during runtime though? anyway thank you for answer 🙂

I’m not sure what you mean, just read and write to it?

```auto

USolusDataSingleton* USolusDataSingletonLibrary::GetSolusData(bool& IsValid)
{
	IsValid = false;
	**USolusDataSingleton* DataInstance = Cast<USolusDataSingleton>(GEngine->GameSingleton);**
 
	if(!DataInstance) return NULL;
	if(!DataInstance->IsValidLowLevel()) return NULL;
 
	IsValid = true;
	return DataInstance;
}

```

This gets you a pointer to thr UObject and then you can access whatever data you have in their. Structs or whatever.

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 12, 2016, 7:09am UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/7 "2016-04-12T07:09:26Z")

</div>

> [@Gigantoad;510963](#):
>
> I’m not sure what you mean, just read and write to it?
> 
> ```auto
> 
> USolusDataSingleton* USolusDataSingletonLibrary::GetSolusData(bool& IsValid)
> {
> IsValid = false;
> **USolusDataSingleton* DataInstance = Cast<USolusDataSingleton>(GEngine->GameSingleton);**
>  
> if(!DataInstance) return NULL;
> if(!DataInstance->IsValidLowLevel()) return NULL;
>  
> IsValid = true;
> return DataInstance;
> }
> 
> ```
> 
> This gets you a pointer to thr UObject and then you can access whatever data you have in their. Structs or whatever.

My English is not mother tongue language, sorry about ambiguous reply. after coffee from a cafe, i will use your code to test it. Thank you So much for your attention.

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 12, 2016, 5:28pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/8 "2016-04-12T17:28:43Z")

</div>

hmmm… still in BP, it works, but when I hit Play Button, My Singleton is not valid… I dunno why. I even set my Singleton as Game Singleton Class in General Setting

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_689e935a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_689e935a](https://forums.unrealengine.com/u/anonymous_user_689e935a)\
**Post date:** [April 12, 2016, 11:35pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/9 "2016-04-12T23:35:38Z")

</div>

Would probably need more specifics to help, some code, what you’re trying to do etc.

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 13, 2016, 8:03am UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/10 "2016-04-13T08:03:52Z")

</div>

Would probably need more specifics to help, some code, what you’re trying to do etc.  
[/QUOTE]

Okay after coffee break, i will submit my code

---

<div class="post-metadata">

**Author:** ![sivan](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sivan](https://forums.unrealengine.com/u/sivan)\
**Post date:** [April 13, 2016, 9:22am UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/11 "2016-04-13T09:22:24Z")

</div>

you can also inspect the game instance class for this purpose…

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 13, 2016, 1:11pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/12 "2016-04-13T13:11:29Z")

</div>

> [@sivan;511852](#):
>
> you can also inspect the game instance class for this purpose…

how can i inspect the game instance?

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 13, 2016, 1:29pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/13 "2016-04-13T13:29:52Z")

</div>

![2016-04-13.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/1/fb19aa3383e8e1c23831c9da0786a656913a1b2b.png)

![2016-04-13 (1).png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/c/b/ccbd676a58a375d37cba328b537f0c6fcbe04aa1.png)

 ![2016-04-13 (2).png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/6/96b91bf422259023102b75629bebdb29fa117355.png)

![2016-04-13 (3).png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/4/4/44a24b95d2ca18c08aa583ebceae1478150a6c92.png)

![2016-04-13 (4).png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/1/9/195edbc4670e9714b27acbff8f11fef06c502d1c.png)

 ![2016-04-13 (5).png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/a/5/a59b01da7acd2e7f233c77bf64b09298b6518f83.png)  
I did same as Rama code and I also modified (delete singleton sentence) DefaultEngine.ini.

why during runtime, my actor cannot get any data from my singleton (and where the heck is my singleton?).

Any suggestion?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_689e935a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_689e935a](https://forums.unrealengine.com/u/anonymous_user_689e935a)\
**Post date:** [April 13, 2016, 2:24pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/14 "2016-04-13T14:24:21Z")

</div>

Well one thing I see instantly is in the last screenshot you have nothing connected to the input pin of GetFolyeDeserterNonCombatAnimation? Never running like that.

---

<div class="post-metadata">

**Author:** ![Jackblue](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jackblue/32/88706_2.png) [@Jackblue](https://forums.unrealengine.com/u/Jackblue)\
**Post date:** [April 13, 2016, 2:27pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/15 "2016-04-13T14:27:43Z")

</div>

> [@Marjane;511971](#):
>
> I did same as Rama code and I also modified (delete singleton sentence) DefaultEngine.ini.
> 
> why during runtime, my actor cannot get any data from my singleton (and where the heck is my singleton?).
> 
> Any suggestion?

You only need to delete the singleton declaration in the DefaultEngine.ini if you delete them and your editor crash at start well you need to edit manually the file.  
Well reset your Singleton Object in your settings and try again, and do some debug stuff like get display name of your Singleton object, this will print something like “GameManagerBP6”, if it does your settings is ok 🙂

I hope this help you ! 🙂

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 13, 2016, 2:59pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/16 "2016-04-13T14:59:22Z")

</div>

> [@Gigantoad;511999](#):
>
> Well one thing I see instantly is in the last screenshot you have nothing connected to the input pin of GetFolyeDeserterNonCombatAnimation? Never running like that.

okay let me fix it. uh… but why instance is not valid? hmmm… let me fix that Animation Function first

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 13, 2016, 3:00pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/17 "2016-04-13T15:00:08Z")

</div>

> [@Jackblue;512003](#):
>
> You only need to delete the singleton declaration in the DefaultEngine.ini if you delete them and your editor crash at start well you need to edit manually the file.  
> Well reset your Singleton Object in your settings and try again, and do some debug stuff like get display name of your Singleton object, this will print something like “GameManagerBP6”, if it does your settings is ok 🙂
> 
> I hope this help you ! 🙂

okay let me try ur advice 🙂 thanks

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_689e935a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_689e935a](https://forums.unrealengine.com/u/anonymous_user_689e935a)\
**Post date:** [April 13, 2016, 3:08pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/18 "2016-04-13T15:08:09Z")

</div>

> [@Marjane;512024](#):
>
> okay let me fix it. uh… but why instance is not valid? hmmm… let me fix that Animation Function first

Yeah that would probably be if you removed the singleton from the DefaultEngine.ini.

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 13, 2016, 3:09pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/19 "2016-04-13T15:09:29Z")

</div>

> [@Jackblue;512003](#):
>
> You only need to delete the singleton declaration in the DefaultEngine.ini if you delete them and your editor crash at start well you need to edit manually the file.  
> Well reset your Singleton Object in your settings and try again, and do some debug stuff like get display name of your Singleton object, this will print something like “GameManagerBP6”, if it does your settings is ok 🙂
> 
> I hope this help you ! 🙂

how do i get display of my singleton? World Outliner does not display anything about it.

---

<div class="post-metadata">

**Author:** ![anon65365138](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anon65365138](https://forums.unrealengine.com/u/anon65365138)\
**Post date:** [April 13, 2016, 3:15pm UTC](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784/20 "2016-04-13T15:15:28Z")

</div>

Okay. Gigantoad you are right. it was the problem with BP, but I face new problem, my animation does not show up… LOL XD anyway thank you so much guys

[Next page](https://forums.unrealengine.com/t/need-help-for-making-singleton-style-uobject-and-other-problems/60784.md?page=2)
