Lag when instancing new node for the first time

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Reitmania

Hey guys,

we are currently working on a small boat game at our university with modular level setup and top view:

The river consists of several tiles, which are randomly stacked to each other. For this, the nodes are instanced via var tile = sceneTileXY.instance()

All tiles are preloaded, but nevertheless a lag appears every time a tile is instanced for the first time. Seems to be comparable to this problem: Lag Spike When Instancing Node For the First Time - unfortunately the solution (presenting all used shaders at the beginning to pre-compile them) didn’t work for us. The tiles are all low-poly, so the complexity of the meshes shouldn’t be a problem.

Do you have any suggestions?

Thx, reiti

:bust_in_silhouette: Reply From: Lopy

This is more of a workaround than a solution, but you could move the lag to a moment where it is less problematic. Make yourself a loading screen, where you instantiate every one of the offending Nodes. That way, it will look perfectly normal, as loading screens naturally tend to have short freezes.

You could either make it look good, or try to hide them as much as possible. For instance, maybe rendering them in a Viewport that is not seen would be enough to “prime” the Node.