Tutorial, optimisations, and different enhancements
Hey everybody, time for one more lengthy overdue replace on what I have been as much as these days! I’ve principally been targeted again on constructing the in-game tutorial state of affairs, however I’ve additionally continued engaged on the sport, each including options to help eventualities, and making different common enhancements.
Efficiency Optimisation
I observed some efficiency points, notably with numerous components or constructions, so I made a decision to spend a while addressing these.
UI optimisations:
- UI components now solely resize themselves to content material when one thing modifications, fairly than each replace.
- Improved efficiency of hyperlink and half intersection indicators when looping by half cases.
- Improved the compass overlay implementation (not units gameobjects lively / inactive).
- Optimised the scene instrument UI’s building record replace.
Different optimisations:
- Eliminated pointless calculations from the development replace perform.
- Eradicated the composite replace perform altogether.
- Eradicated or simplified another mounted replace features.
These modifications save over 1 ms on the principle thread when there are lots of components / constructions within the scene (totalling a pair thousand components or so).
Talking of which, I’ve additionally investigated utilizing Unity jobs to maneuver work off the principle thread. This has the potential for some extra important efficiency enhancements.
This is what I’ve deliberate:
- 1) Gear and pulley wheel behaviour constraint updates – The code that figures out if a pair of gears are engaged, and the placement of their engaged “enamel” (information that is then used to replace the ConfigurableJoints). This may very well be carried out in parallel in jobs I feel.
- 2) Wheel behaviour constraint updates – Every wheel does a CapsuleCast and another trickery to approximate a cylinder that easily rolls on the bottom. This can be a prime candidate for utilizing the CapsulecastCommand as an alternative.
- 3) Half choice’s “discover legitimate attachments” code – Does lots of OverlapBox calls if numerous components are chosen, must be excellent case for changing with the OverlapBoxCommand.
- 4) Collision contact reporting (used for impression sounds and so on.) – Horribly inefficient in the mean time, however Unity simply launched the Physics.ContactEvent, which must be precisely what I would like to enhance this.
All however the first of those duties would require upgrading to Unity 2022.2 although, which feels a bit dangerous in the mean time. I’ll maintain off till the LTS model comes out.
Unity 2021 improve
Within the meantime nevertheless, I’ve upgraded to Unity 2021.3 LTS. I had tried upgrading to 2021 some time in the past, however discovered a few sport breaking points. These appear to have been mounted now, and the improve went fairly easily this time.
The one slight challenge is that outdated saved building preview photos now will not load (compressed picture measurement must be a number of of 4), however this may be resolved simply by re-saving them first.
Constructing enhancements
I’ve made varied minor enhancements and fixes to the constructing system:
- The half choice pivot level can not be moved under the bottom, stopping a building from being “misplaced” underground.
- Now solely the transfer manipulator deal with has “drag thresholding”, the interpretation handles transfer immediately.
- Engagement indicators are actually proven for all gears within the half choice throughout alignment.
- Instructions are actually added to the undo / redo historical past when hyperlinks are eliminated whereas detaching components.
- Fastened a bug the place destroying an unfrozen building did not add a command to the undo / redo historical past.
Elements
I’ve additionally made a couple of minor enhancements and additions to the components:
- Carried out a resizable “L Plate” half, helpful for connecting stuff at proper angles.
- Added checks for participant distance and dealing with route to the management wheel half behaviour (prevents the management wheel from getting used when the participant is simply too distant).
- Added a light-weight half behaviour choice to disable shadow casting, helpful if you wish to save efficiency for a building with numerous lights.
- Fastened a bug the place spring damper / linear actuator pistons may very well be connected to the incorrect alignment level.
This is what the L Plate half seems to be like:
Lua scripting
I’ve labored on varied new options which can be obtainable to be used from inside Lua scripts (as eventualities or script mods), principally to help what I would like for the tutorial state of affairs.
Video participant
Carried out an in-game video participant, with an interface that enables video gamers to be created from Lua scripts. This is a take a look at Lua script, exhibiting a video enjoying in a window:
I am planning on utilizing this to point out quick explanatory video clips within the tutorial state of affairs.
Scroll record UI factor
Carried out a scroll record UI factor, could be added to a window like every other factor, however then different components could be added to it (together with extra scroll lists!) For instance the undo / redo command historical past script mod can now present a bigger historical past that may be scrolled by:
Unlabelled UI components
Added unlabelled variants of the slider, enter area, and dropdown UI components for extra flexibility. Proven right here on this Lua UI unit take a look at:
Profiling metrics
Uncovered efficiency profiler metrics (e.g. reminiscence, rendering and so on.), in order that script mods can implement customized profiler UI home windows, for instance:
Tutorial state of affairs
My authentic plan was to have a number of little tutorial eventualities, each introducing a couple of new ideas at a time. As I discussed in a earlier publish, this concept turned out to be a bit boring in follow, and did not actually create a great first impression for the sport.
So then I pivoted to having one massive state of affairs with lots of issues to do in it, basically combining the separate tutorials into one which can be adopted by step-by-step. Nevertheless as I began to construct this out I realised it was getting too huge and complex. Other than the rest, efficiency was attending to be marginal with a lot happening within the scene directly.
So, I went again to the drafting board and reworked my design, attempting to essentially deal with what ideas I needed to introduce in every tutorial stage, and what ideas to bolster from earlier phases.
The outcome is a little more pared again than what I had earlier than, however I feel it ought to nonetheless be enjoyable. It is going to nonetheless be a single state of affairs / scene containing a number of actions that the participant goes by, however with much less extraneous stuff.
The primary few actions will get the participant used to activating and utilizing half behaviours, utilizing the development menu, and so forth.
After which, every exercise would require the participant to do one thing (e.g. connect a management wheel, reposition a gear, hyperlink some pulleys, and so on) that may permit them to open a field with an element inside. Once they’ve accomplished all of the actions they’ll accumulate all of the components collectively and construct one thing out of it, as the ultimate step (utilizing every little thing they’ve realized thus far).
For instance, the primary of those actions is to easily use the builder instrument to maneuver a weight and place it on a platform. Issues ramp up in complexity from there!
The design is now full, I’ve constructed all the person constructions for the state of affairs, and made a great begin on the Lua scripting. I am planning on making one other (small) map for the sport, for use for this tutorial (and any others to comply with).
This tutorial state of affairs is actually there to get new gamers used to utilizing the constructing controls, it does not go a lot past that. I wish to additionally construct extra tutorial eventualities that train superior use of gears, mechanical ideas, have extra advanced puzzles to unravel and so on. These must come after the early entry launch although.