Async creation of ProceduralMeshComponent

How to create a PMC mesh in a async thread?
I’m trying FRunnable but get an assertion.
Cant find any examples online.

hard to tell without knowing the code and the error.

Try looking for examples of procedural mesh component and Runnable threads separately. Unreal Wiki is quite useful there.

Well the thing is the Unreal does not give me information either. Maybe people here have some examples.
What i do is i create a FRunnable

something like:


class MyRun : public Frunnable
{
UProceduralMeshComponent* pmc;
...
void Run()
{
 pmc ->CreateMeshSection(...); //here breaks exception
}
}

I don’t know about that. Couldn’t find anything useful there.

These two are complex topics, so having a tutorial which has both of them implemented, is a luxury to ask, but I’m sure if you dig well enough you can find some code snippets or references.
For now I have links of wiki for procedural mesh and multi-threading separately.
:slight_smile:

did you check if pmc is null?

This is the way you initialize the Thread.


//***********************************************************
//Thread Worker Starts as NULL, prior to being instanced
//        This line is essential! Compiler error without it
FTaskCreateStreets* FTaskCreateStreets::Runnable = NULL;
//***********************************************************



Yes i did.
I’ve seen mention that you can create any UObjects or actors in any other thread than main thread.
Probably that is the problem.
Any ideas how to call function on main thread form a Runnable?

Thanks for help, dude. But thread is fine. :slight_smile:

TFuture<void > future=Async (EAsyncExecution::Thread, &]()
{

    //run code in different thread

    Async(EAsyncExecution::TaskGraphMainThread, &]
    {
        ChangeGameState(EGameStatus::GAMEPLAY);//callit on game thread

    });



});

TFuture<void > future=Async (EAsyncExecution::Thread, &]()
{

//run code in different thread

Async(EAsyncExecution::TaskGraphMainThread, &]
{
ChangeGameState(EGameStatus::GAMEPLAY);//callit on game thread

});



});