Hi,
I call a function called
twinkleDamage
when my enemy is touched.
I tried many different AsyncTask(ENamedThreads::XXX)
and it seems that more prioritized is the thread, the more the game freeze when the thread is called.
VisualStudio break point when FPlatformProcess::Sleep is called
void AMyBasicMob::twinkleDamage()
{
AsyncTask(ENamedThreads::AnyBackgroundHiPriTask , [this]() // GAMETHREAD ???
{
int i = 0;
bool val = false;
auto _mesh = this->GetMesh();
if (_mesh) {
while (i < 14) {
UE_LOG(LogClass, Warning, TEXT("FLICKER LOOP"));
if (!val) {
_mesh->SetMaterial(0, FlikkerMaterial);
}
else {
_mesh->SetMaterial(0, BaseMaterial);
}
// HERE ISSUE
// trigger breakpoint or crash
FPlatformProcess::Sleep(0.03);
////////////////
///////////
val = !val;
i++;
}
_mesh->SetMaterial(0, BaseMaterial);
this->hitable = true;
}
});
}
As you probably guest, I’m a newbie in UE4, but I’ve done many c++ projects by the past,
So somebody can tell me what’s wrong here?
Or If you have a best practice for thread that handle visual modification of actor, let me know!
thanks