Download

Execution of code on the game thread

Hello,
We are using UE4 as a viewer for a simulation engine running in a separate process. The communication runs on a separate thread and one AActor-derived object takes care of updating everything in its Tick function. Everything runs great and my client is happy.

Now we would like to handle queries from the simulation engine such as the terrain height at a given coordinate. The issue is that the Tick is called roughly at the FPS, so if I’m running at around 60FPS, it takes up to 16ms for the Tick to be called and process the request.

Since the request has to be processed in the game loop (access to AActor data, ray-casting…), is there any way to wake up the game thread “immediately” even while it’s waiting to synchronize itself with the render loop? I’ve tried posting tasks from the communication thread with AsyncTask(ENamedThreads::GameThread, …) but as far as I can tell, the task were just queued and processed on the next game loop iteration.

Are there any other mechanism in UE4 that would allow me to approach the issue?

Is this even worth doing? An end user will never realize the difference. Not to mention render thread and game thread are almost always a few frames apart…