# Could someone make a tutorial on how to add a Global Class & expose it to Blueprints?

**URL:** <https://forums.unrealengine.com/t/could-someone-make-a-tutorial-on-how-to-add-a-global-class-expose-it-to-blueprints/76313>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [October 18, 2016, 5:27pm UTC](https://forums.unrealengine.com/t/could-someone-make-a-tutorial-on-how-to-add-a-global-class-expose-it-to-blueprints/76313 "2016-10-18T17:27:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KidBuu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@KidBuu](https://forums.unrealengine.com/u/KidBuu)\
**Post date:** [October 18, 2016, 5:27pm UTC](https://forums.unrealengine.com/t/could-someone-make-a-tutorial-on-how-to-add-a-global-class-expose-it-to-blueprints/76313/1 "2016-10-18T17:27:43Z")

</div>

So I’m 100% new to the Unreal Engine, and I’d like to create a C++ class using the “None” option, as shown in this picture…

 ![d9ab3b352f.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/8/3/f83ac14dc3bfe1f6d50420ab053aa2259f20ffeb.png)

I chose “None”, because the class I am implementing will not be spawned in game (at least not visually). It should be a Global object, I don’t need to be able to reference the variable holding the object globally, I only need its lifetime to exist until the game ends (I also need to find out how to do this).

The purpose of this custom class is to work as a networking interface for a 3rd party server that I’ve developed, did I choose the correct C++ class type for this? I think I did, but a more seasoned Unreal Developer may know better. In other words I need to be able to call at it to send data to the server, and then I need it to be able to call another interface (not yet made) that handles responding to server messages and applying their functionality/instructions. In my own first example I’ve created a UMG Login Screen, and when the user clicks “Login” I want it to create an instance of this new Class that lives until the client disconnects from the game. However, when I go to the Login Button onClicked event in BluePrints the class is no where to be found.

When I try to make the Class & expose it to Blue prints, I get errors… These ones to be exact.  
 ![d38dd5d73c.png]()

From this I’m understanding that I need to inherit from UObject, but why…? Even if I do inherit from UObject, I still get these errors…  
 ![8b3a2c3c6b.png]()

This is my code…  
**TestClass.h**

```auto

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

/**
 * 
 */
UCLASS(BlueprintType, Blueprintable)
class GAMECLIENT_API TestClass : public UObject
{
public:
	TestClass();
	~TestClass();
};

```

**TestClass.cpp**

```auto

// Fill out your copyright notice in the Description page of Project Settings.

#include "GameClient.h"
#include "TestClass.h"

TestClass::TestClass()
{
}

TestClass::~TestClass()
{
}

```

---

<div class="post-metadata">

**Author:** ![n00854180t](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@n00854180t](https://forums.unrealengine.com/u/n00854180t)\
**Post date:** [October 18, 2016, 10:10pm UTC](https://forums.unrealengine.com/t/could-someone-make-a-tutorial-on-how-to-add-a-global-class-expose-it-to-blueprints/76313/2 "2016-10-18T22:10:58Z")

</div>

## Hey OP, I’m going to move this to the C++ forum, I think you’ll get better traction on your question there.

As for your problem, I’m not totally sure but you may need to have an Engine.h include somewhere.

---

<div class="post-metadata">

**Author:** ![HateDread](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HateDread](https://forums.unrealengine.com/u/HateDread)\
**Post date:** [October 18, 2016, 10:45pm UTC](https://forums.unrealengine.com/t/could-someone-make-a-tutorial-on-how-to-add-a-global-class-expose-it-to-blueprints/76313/3 "2016-10-18T22:45:53Z")

</div>

If you’ve got ‘OtherCompilationError’ in the error list, you should look at the Output/Debug window for more details. Paste those here!

---

<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:** [October 19, 2016, 12:48am UTC](https://forums.unrealengine.com/t/could-someone-make-a-tutorial-on-how-to-add-a-global-class-expose-it-to-blueprints/76313/4 "2016-10-19T00:48:55Z")

</div>

Unreal Engine has an object which exist during all the existence of the instance, its name is GameInstance.

Once you create your GameInstance, you need to declare it inside your Project Settings, Maps & Mode and set your GameInstanceClass.

You are free to declare all you need inside your Custom GameInstance, but you can also create a UObject and create it inside the constructor, you need to use:

```auto

 CreateDefaultSubobject<T>(TEXT("NameOfYourObject") 

```

else you can also override the Init() function and simply use:

```auto

NewObject<T>(this) //Don"t forget the 'this' pointer, if you didn't set it your object will be garbage collected

```

Note: Don’t use NewObject\<T\>() inside a constructor.

After it’s easy to access the GameInstance, any Actor have an GetGameInstance Node, cast to your custom one and get what you need (if it’s your UObject don’t forget to add BlueprintType to the UCLASS() declaration).

---

<div class="post-metadata">

**Author:** ![rincom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rincom](https://forums.unrealengine.com/u/rincom)\
**Post date:** [February 10, 2017, 1:41pm UTC](https://forums.unrealengine.com/t/could-someone-make-a-tutorial-on-how-to-add-a-global-class-expose-it-to-blueprints/76313/5 "2017-02-10T13:41:01Z")

</div>

Hey, maybe this is what you want

> **[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 — ue4community.wiki! You will be able to find content from the official...

Is this?
