# Creating Non-Actor Objects

**URL:** <https://forums.unrealengine.com/t/creating-non-actor-objects/443800>\
**Category:** World Creation\
**Tags:** world, engine-compile, unreal-engine, level, objects, CPP, question\
**Created:** [February 21, 2019, 1:16pm UTC](https://forums.unrealengine.com/t/creating-non-actor-objects/443800 "2019-02-21T13:16:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![TUGRUL\_SERT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TUGRUL\_SERT](https://forums.unrealengine.com/u/TUGRUL_SERT)\
**Post date:** [February 21, 2019, 1:16pm UTC](https://forums.unrealengine.com/t/creating-non-actor-objects/443800/1 "2019-02-21T13:16:03Z")

</div>

I learned that the actors belong to the level, so I want to create non-actor objects. because I want my objects never to destroy. The Objects I’ll create must not have SceneComponent. They’re not actor, only the objects I will use to manage the whole game. I want to create something out of the game world.

I usually don’t prefer to use GameFramework(GameMode etc.) and Blueprint.

 ![269154-my.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/f/6df71892ddb8802a7fdb5b9557923ba9cc712c63.png)

For example, I’ll tell GameManager to load LoginLevel, when the game is loaded for the first time

```
class ClientManager : UObject 
{
    CLASS_NAME _myNetwork; // my network library (using winsock/berkeley sockets)
    // To connect to server,create clients .. ...
} 

class MapManager : UObject
{
   MAP_OBJECT // holds NPCs, Characters in level.

   LoadLevel(); UnloadLevel();
}
class GameManager : UObject{ // It will store some game information and has some functions...}

```

When press the login button in the Login Level or a player is in teleportation zone in xxx\_level, the loadmap function will be called.

Also I want my objects to have functions like tick, beginplay.

Let me briefly summarize the life cycle I want to create,

Engine-\>Call my objects functons-\>Call level actors functions

**If these are impossible, could you give me alternative ways and advices?**

---

<div class="post-metadata">

**Author:** ![madturtleGGinin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@madturtleGGinin](https://forums.unrealengine.com/u/madturtleGGinin)\
**Post date:** [February 22, 2019, 10:51am UTC](https://forums.unrealengine.com/t/creating-non-actor-objects/443800/2 "2019-02-22T10:51:44Z")

</div>

For this use case you should make a custom GameInstance, and create your manager objects from there.

```
class MyGameInstance : public UGameInstance
{
 private: 
	UPROPERTY()
	UGameManager * GameManager ; 
    // UPROPERTY() is necessary to prevent from being garbage collected
}

```

You’ll also need to change the default GameInstance from Project Setting:

`Edit->Project Settings->Maps & Modes->GameInstanceClass -> "MyGameInstance"`

GameInstance don’t have Tick function, but you can achieve the same thing using a looping timer.

---

<div class="post-metadata">

**Author:** ![TUGRUL\_SERT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TUGRUL\_SERT](https://forums.unrealengine.com/u/TUGRUL_SERT)\
**Post date:** [February 22, 2019, 5:43pm UTC](https://forums.unrealengine.com/t/creating-non-actor-objects/443800/3 "2019-02-22T17:43:49Z")

</div>

Could you explain the “Looping Timer” a little more?

And I have one more question.

There is a GameLoader widget.&nbsp;Let’s say we call these functions in sequence :

A()-\>B()-\>C()-\>D()

The game is working in the GameThread. When I change a widget of the GameLoader in the ‘A’ function (for example: Loading.Text = “Function ‘A’ is called!”), it won’t change until other functions are called, right?

I want it to render when A function called.&nbsp;Do I have to use one more thread? Are Widgets or UObjects thread-safe?

```
A(){
         Loading.Text = "...."
         RenderWidget()
         B()
}

```

Or Should I use Tick() and call functions in turn?

```
Tick()
{
if........

 First Frame Call A() return
 Second Frame Call B() 
.....
....
}

```

It sounds like a very challenging and amateurish. What do you think about this?

Thanks.

---

<div class="post-metadata">

**Author:** ![madturtleGGinin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@madturtleGGinin](https://forums.unrealengine.com/u/madturtleGGinin)\
**Post date:** [February 24, 2019, 11:10am UTC](https://forums.unrealengine.com/t/creating-non-actor-objects/443800/4 "2019-02-24T11:10:15Z")

</div>

By looping timer I mean set a Timer using TimerManager with the `bLoop` parameter set to true.

Here is the documentation of TimerManager:

> **[FTimerManager](https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/FTimerManager/)**
>
> Class to globally manage timers.

Here’s an example:

```
class UMyGameInstance: UGameInstance{
  FTimerHandle TickHandle;
  void Tick(){ /* Do tick stuff */}
  virtual void Init() override
  {
    Super::Init();

    // Call Tick() once per second
    GetTimerManager().SetTimer(TickHandle, this, &MyGameInstance::Tick, 1, true);
  }
}

```

Your second question can be also be achieve by TimerManger. Either using a custom delay time or `SetTimerForNextTick`:

> **[FTimerManager::SetTimerForNextTick](https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/FTimerManager/SetTimerForNextTick/4/)**
>
> Sets a timer to call the given native function on the next tick.

So your function “A” will look like this:

```
    void MyGameInstance::UpdateWidget(){
      Loading.Text = "...."
      RenderWidget()
      GetTimerManager().SetTimerForNextTick(this, &MyGameInstance::B);
    }
```

---

<div class="post-metadata">

**Author:** ![TUGRUL\_SERT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TUGRUL\_SERT](https://forums.unrealengine.com/u/TUGRUL_SERT)\
**Post date:** [February 24, 2019, 1:44pm UTC](https://forums.unrealengine.com/t/creating-non-actor-objects/443800/5 "2019-02-24T13:44:58Z")

</div>

It works. Thanks.

---

<div class="post-metadata">

**Author:** ![madturtleGGinin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@madturtleGGinin](https://forums.unrealengine.com/u/madturtleGGinin)\
**Post date:** [February 25, 2019, 4:23pm UTC](https://forums.unrealengine.com/t/creating-non-actor-objects/443800/6 "2019-02-25T16:23:21Z")

</div>

An upvote or marking as accepted would be nice.

---

<div class="post-metadata">

**Author:** ![TUGRUL\_SERT](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TUGRUL\_SERT](https://forums.unrealengine.com/u/TUGRUL_SERT)\
**Post date:** [February 25, 2019, 4:52pm UTC](https://forums.unrealengine.com/t/creating-non-actor-objects/443800/7 "2019-02-25T16:52:36Z")

</div>

Sorry, I’m kinda new here. 🙂
