\nIf it takes as long as the join time, because all the components are close to each other, I fear it might lag the game quite a lot.
\nBut this is just speculation.
If you’ve built large machines in Logic World, you’ll know that loading times can get veeerrrry long. A big goal of mine for update 0.91 is to dramatically improve this, and make the game load even very large contraptions quickly.
As a case study, we’ll use the FML-8 8-bit CPU by Stenodyon. This sandbox is ~6MB, containing ~70,000 components and ~80,000 wires. On my machine, it takes about 75 seconds to load in version 0.90. If you build even bigger, the loading times only get worse; I’ve heard of some extreme cases taking multiple hours to load. This sucks, so let’s fix it!
Upon investigation, it turns out that most of this loading time is spent on creating collider objects. Colliders are 3D shapes that define a collision boundary, and every object you place in Logic World needs a collider. Colliders are what allow for intersection tests: they let us know what object the player is looking at, they allow you to stand on an object without falling through it, and they enable us to test if a new object placement is clear of obstructions.
Logic World uses the built-in Unity collider system. This system was never intended to support a case like Logic World, where you need to quickly create hundreds of thousands of colliders. To improve loading times, we’ll simply need to use fewer colliders.
To this end, I’ve implemented a “virtual colliders” system. Each object that requires a collider stores lightweight data about its collider, but it doesn’t necessarily have an actual instantiated collider object. The full colliders are only instantiated when needed – i.e, when the player is nearby. This results in a “bubble” of colliders around the player, where they’re needed. Colliders far away from the player simply don’t exist until the player goes there.
Here’s a video demonstrating this system. The green outlines correspond to instantiated collider objects. Notice how they disappear when the player leaves the area.
The results so far have been very promising. While FML-8 took ~75 seconds to load in 0.90, I’ve got that time down to 11.8 seconds in my development version. That goes further down to 4.7 seconds on a warm reload (loading into a world for the second time, so the game already has some stuff cached).
This refactoring is taking a lot longer than I expected. Quite a few places in the code assume that an object in the world will always have an instantiated collider, and all of these places need to be accounted for. I do expect it will be finished up soon though.
Optimization is and will always be a focus of Logic World development. I want players to build as big as they can dream, and we’ll continue to work to expand the scope of what it’s possible to create in this game. The virtual colliders system is just the first in a long series of post-launch upgrades that will make Logic World faster, smoother, and more scalable.
Until next time :)