Moynzy
(Moynzy)
1
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Engine/GameInstance.h"
#include "MyGameInstance.generated.h"
/**
*
*/
UCLASS()
class GAMESGROUPPROJECT_API UMyGameInstance : public UGameInstance, public FRunnable
{
GENERATED_BODY()
public:
virtual bool Init();
virtual uint32 Run();
virtual void Stop();
FSocket* mySocket;
UMyGameInstance(const FObjectInitializer& ObjectInitializer);
UFUNCTION(BlueprintCallable, Category = "Server")
bool hasConnected();
bool isConnected = false;
};
As you can see, virtual bool Init(); gives me an error.
How do I over ride this?
As error say, decleration needs to be the same and original function is returning void not bool:
also you should use override keyword, otherwise you will just hide parent function
virtual void Init() override;
Also this is not multithreading just overriding ^^’
I don’t think so never did multithreading on UE4, it should give you error duing building if thats the case.
Moynzy
(Moynzy)
5
Yo, thank you!
But I extend of FRunnable, and it requires to return an Int right?
Moynzy
(Moynzy)
6
Sorry, I meant, FRunnable`` interface means you must have
virtual bool Init()
virtual uint32 Run();
virtual void Stop();
Stupidly the game instance class has a function called “void Init()” as well.
How can I target the interface Runnable, and not the base class Init.
Do you know what I mean?
Moynzy
(Moynzy)
7
As you know, the game instance class will persist from level to level, until the game is destroyed.
With this I can make sure my client will always be connected to my third party server.
But I need a run a thread, so it can listen on updates from the third party server.
Game Instance does not have a void onTick, therefore I can’t use that thread.