I am trying to create a blueprint node that does about a minute worth of work asynchronously when activated. Obviously, I don’t want to lock up my game while saving my game to the cloud.
I would prefer to do one node in C++, rather than a huge flowchart of hundreds of individual functionality nodes.
I need to batch save a bunch of game data from my game client to an online service, and it requires a bunch of http api calls (I can already do this part myself).
I am trying to figure out the interaction between a blueprint node and an OnTick function. It is supposedly possible, but there’s no documentation geared towards this goal. The only real direct mention about it is here:
MyTestNode.h file:
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnMyTestCompleted);
class UMyTestNode : public UOnlineBlueprintCallProxyBase
{
GENERATED_UCLASS_BODY()
public:
virtual void Activate() override;
bool OnTick(float deltaTime);
void Finish();
// Some UPROPERTY stuff
private:
TBaseDelegate<bool, float> tickHandler;
FOnMyTestCompleted m_OnMyTestCompleted;
}
MyTestNode.cpp file:
UMyTestNode::UMyTestNode(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
tickHandler = FTickerDelegate::CreateRaw(this, &OnTick); // <<--------------THIS LINE DOESN'T COMPILE
}
void UMyTestNode::Activate()
{
UE_LOG(LogTemp, Log, TEXT("Test Node activated"));
auto onTickHandle = FTicker::GetCoreTicker().AddTicker(tickHandler);
FTicker::GetCoreTicker().RemoveTicker(onTickHandle); // note, move to finish when I solve the CreateRaw problem
}
bool UMyTestNode::OnTick(float deltaTime)
{
UE_LOG(LogTemp, Log, TEXT("Test Node OnTick"));
// note, lots of http work here (really it calls to another pre-existing file)
// note, manually call Finish() when everything is done
}
void UMyTestNode::Finish()
{
UE_LOG(LogTemp, Log, TEXT("Test Node finished"));
if (m_OnMyTestCompleted.IsBound())
{
m_OnMyTestCompleted.Broadcast();
}
}
UMyTestNode* UMyTestNode::MyTestNode()
{
UMyTestNode* nodeInstance = NewObject<UMyTestNode>();
return nodeInstance;
}
How do I correctly invoke CreateRaw? It seems to exactly match existing examples and documentation. But it won’t compile in my file.
Is there a guide or documentation that I haven’t found yet for this purpose?