Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Creating Non-Actor Objects

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.

alt text

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?

Product Version: Not Selected
my.png (18.0 kB)
more ▼

asked Feb 21 '19 at 01:16 PM in C++ Programming

avatar image

10 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

 class MyGameInstance : public UGameInstance
     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.

more ▼

answered Feb 22 '19 at 10:51 AM

avatar image

346 1 4 4

avatar image TUĞRUL SERT Feb 22 '19 at 05:43 PM

Could you explain the "Looping Timer" a little more?

And I have one more question.

There is a GameLoader widget. Let's say we call these functions in sequence : 


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. Do I have to use one more thread? Are Widgets or UObjects thread-safe?

          Loading.Text = "...."

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

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

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


avatar image madturtleGGinin Feb 24 '19 at 11:10 AM

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

Here is the documentation of TimerManager: https://api.unrealengine.com/INT/API/Runtime/Engine/FTimerManager/

Here's an example:

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

     // 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: https://api.unrealengine.com/INT/API/Runtime/Engine/FTimerManager/SetTimerForNextTick/4/index.html

So your function "A" will look like this:

     void MyGameInstance::UpdateWidget(){
       Loading.Text = "...."
       GetTimerManager().SetTimerForNextTick(this, &MyGameInstance::B);
avatar image TUĞRUL SERT Feb 24 '19 at 01:44 PM

It works. Thanks.

avatar image madturtleGGinin Feb 25 '19 at 04:23 PM

An upvote or marking as accepted would be nice.

avatar image TUĞRUL SERT Feb 25 '19 at 04:52 PM

Sorry, I'm kinda new here. :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question