The last remaining bugs caused by the Unity 5 upgrade (at least, those that I’m aware of) have now been fixed. In the end I decided to postpone migrating away from the deprecated APIs for now as the game still builds ok without doing this (albeit with some warnings), and it’s been so long since the last build – I wanted to get one out as soon as possible!
New world tool
There is now a “world tool” in the game (that can be activated by pressing 0), and with this tool active, holding / pressing Q brings up the world tool UI. In this UI you’ll find the world constructions tab (moved over from the builder tool UI). You’ll also find a new “settings” tab that allows global settings to be changed during gameplay. You can change things such as the current time of day, but perhaps more interesting are the new simulation settings.
These allow you to adjust the trade off between physics simulation accuracy and performance. For example, if you have a slow computer, you can reduce accuracy to get a better frame rate. Or, if you have a model that requires higher physics accuracy, you can increase it at the expense of performance.
Here’s a brief explanation of these settings:-
Update rate – This slider sets the number of times per second that the physics simulation is updated. The higher the update rate, the smaller the time step from one update to the next which gives greater accuracy, at a higher performance cost. The sim time step is particularly important for constructions that have parts with high velocities, especially large angular velocities (i.e. high RPMs). In these cases, it may be necessary to increase the update rate to prevent instability or “glitching”.
Constraint accuracy – This slider controls how tightly rotary bearings, linear bearings, and so on are constrained (how little they “sag”). It also affects how much torque gears can transfer without slipping. If a construction has parts that exert large forces between moving attachments or gears, this may need to be increased (again, the downside being reduced performance).
A science experiment
As (I think) an interesting aside, it turns out that actually two factors affect how accurately constraints are resolved. Increasing the number of physics solver-steps-per-update increases constraint accuracy, but so does reducing the simulation update time step. However, I want the player to be able to adjust the sim update rate without also affecting constraint accuracy, so I did an experiment in the game to try and figure out how to keep a consistent level of constraint accuracy while varying the time step.
I built a construction that put some gears under torque loading (using a lever and a big weight on the end to provide the torque loading). At various sim update time step settings, I adjusted the number of solver-steps-per-update to just the point where the gears no longer slipped.
Plotting these results out on a graph showed what looked to be some kind of power relationship. With a little help from Wolfram Alpha, I found that yes indeed the number of solver steps required was proportional to the time step raised to a power – a power of 2 in fact, handily enough!
So, now I set the number of solver-steps-per-update equal to the square of the time step multiplied by the constraint accuracy value that the player can adjust, and this gives a nice consistent behaviour.
Collision behaviour improvements
You can no longer accidentally deselect or unfreeze constructions under the ground or inside other constructions (this used to generate large impulses as the physics engine tried to resolve the collisions, flinging stuff all over the place). For the same reason, I have also prevented collisions between frozen constructions and the player or other non-frozen constructions. This has the added benefit that you can now walk inside frozen constructions to get a different perspective when building them!
Well, this is a big update for GearBlocks with lots of changes, particularly the Unity 5 upgrade. There could still be bugs or problems introduced that I haven’t spotted yet, so do please let me know if you find any, thanks!