The new builder tool
Hi everyone, I’ve now updated the demo main branch on Steam with all the builder tool changes from the past several months, so I thought it would be a good idea to summarise everything here.
Part multi-selection
The builder tool controls for part selection and movement hadn’t really changed much since early on in the project. Left clicking on a part in a construction would toggle selection on, and then the mouse (and player movement keys) would move the whole construction around. Clicking again would deselect (and unfreeze) it. Holding the right mouse button on a part would detach it from the rest of the construction.
However, I wanted to introduce the ability to select multiple parts of a construction and manipulate them together, independently of the rest of the construction. The old selection controls didn’t adapt well to this, so I re-implemented them to adopt a “drag and drop” paradigm.
So now, left clicking on a part selects only that part (not the whole construction). To move the selection around the left mouse button has to be held down while dragging, and releasing the button will stop moving it, leaving it frozen in place. Releasing the selection while aligning it to another frozen part will attach it to that part.
The right mouse button no longer detaches a part (it now always deletes it), because a part can be detached simply by selecting and dragging it away from the rest of construction.
In order to select multiple parts of a construction, holding left control and left clicking on a part will add or remove it from the selection. Then, all selected parts can be moved around together, allowing for easier modification of sub-sections of a construction.
Often it’s still useful to move an entire construction around, and to do this all of its parts must be selected to avoid breaking it apart. Holding left control and pressing A while targeting a construction provides an easy way to do this.
Finally, left clicking while not targeting anything will deselect any parts currently selected.
I’ve also tweaked the part highlighter rendering to more clearly convey the distinction between unfrozen, frozen, selected, and targeted parts. Frozen parts are outlined in blue, selected parts in orange, and the targeted part in white. An example of this can be seen here:
Move manipulator
Building on the part selection changes, I wanted to introduce the concept of manipulators, kind of like “sub tools” within the builder tool itself. The idea being that they provide an easier and more obvious way to perform certain transformations on the selection (e.g. translation, rotation, etc.) The first of these to discuss is the move manipulator, I’ll go over the others later on.
The first step was to implement a way to author pivot points for all of the parts, and to make it possible for the player to target and select them. The selected pivot point then provides the anchor for transforming the selection with the manipulators (being the centre of rotation for example). The targeted pivot point is indicated by a small circle as can be seen in the previous image.
Next, I factored out the code for clicking and dragging the selection from the builder tool, forming the basis of the new move manipulator. It provides drag and drop behaviour in much the same way as before, except that I also added a more obvious draggable “handle” (positioned at the selected pivot point). Pivot points can only be targeted on selected parts, but clicking and dragging on an unselected part will select it and also select the closest pivot point all in one go, as a shortcut to help speed up building.
Once a pivot point is selected, the selection is detached from any unselected parts in the rest of the construction, and the move manipulator handle appears as a larger circle, as seen below.
In the example shown the selection is being aligned to another frozen part, and a valid attachment is possible, so the selection is outlined in green. If the attachment was not valid (e.g. due to part interpenetration) it would be outlined in red.
By clicking and dragging the move manipulator handle, the selection can be moved, allowing it to be repositioned, aligned for attachment, or detached altogether.
The pivot point can be deselected by left clicking while not targeting a selected part, this will attach the selection to any other parts it’s being aligned to (if a valid attachment is possible).
I also carried over the shortcut keys for use while dragging the move manipulator handle. Holding down left shift and moving the mouse translates the pivot point (moving the selection under the crosshair). Holding down left shift and using the directional keys (e.g. WASD) will rotate the selection in 90 degree steps. Holding down left control and using the directional keys will resize the selected part (if applicable).
These shortcuts are mostly the same as with the original building controls, even holding the right mouse button to rotate the selection with the mouse still works, for those who are used to the old way.
Recap of the builder tool controls
Selecting parts:-
- LMB to select the targeted part (and deselect all others).
- Left control + LMB to add or remove the targeted part from the selection.
- Left control + A to select all parts of the targeted construction (and deselect all others).
- LMB while not targeting any parts to deselect all.
Moving the selection:-
- LMB on a selected part (or hold LMB and drag on any part) to:-
- Select the targeted pivot point.
- Show the move manipulator.
- Detach the selection from any unselected parts in the rest of the construction.
- Hold LMB and drag the move manipulator handle to move the entire selection, align it to other frozen parts, and so on.
- LMB while not targeting a selected part to:-
- Attach the selection to any other parts it’s being aligned to.
- Hide the manipulator.
- Deselect the pivot point.
Shortcuts while dragging the move manipulator handle:-
- Hold left shift and move the mouse to translate the selection under the crosshair.
- Hold left shift and use the directional keys to rotate the selection in 90 degree steps.
- Hold left control and use the directional keys to resize the selected part.
- Hold RMB (or left shift + RMB) for legacy mouse rotation.
- Mouse wheel (or hold left alt and use mouse) to “dolly” the selection.
Other:-
- Hold RMB to delete the targeted part.
- Left control + D to duplicate the targeted part.
- Left control + F to freeze / unfreeze the targeted part.
There is a lot to remember here, but the in-game UI overlays are there to provide a reminder of the available actions and key bindings in the current context.
Alignment targeting
Until now, to align and attach the selection to another frozen part, the crosshair would have to be directly over the frozen part being aligned to. I don’t think this is very intuitive, so I re-implemented the system to use a volume based on the selected pivot point to find the part to align to.
Before, a Raycast would be fired forward from the player’s viewpoint to find the part. Instead now, it uses a BoxCast (again directed forward from the player’s viewpoint). A part’s selectable pivot points are typically grouped together, and the group containing the selected pivot point determines the size of this box. For some parts (such as beams and plates) the box happens to encompass the whole part, for others (such as gears and wheels) it does not.
The image below shows one beam being aligned to another without the frozen one needing to be directly under the crosshair.
In some cases however, the more precise Raycast method is still preferable. For example, inserting a beam in between two other beams is hard to do with a BoxCast, because the selection will tend to align to the outside of one of the beams, as shown here.
So the final solution I came up with was a combination of both methods. First a Raycast is tried, and then if that doesn’t find a part to align to, the BoxCast is attempted as a second step. This allows for more precise targeting when needed by aiming the crosshair over the desired part. In the beam example, this makes it easier to insert the part, as shown below.
The other manipulators
In addition to the move manipulator, I’ve also implemented manipulators specifically for translating, rotating, and resizing the selection. These manipulators can be switched between using the R, T, and Y keys respectively. Pressing the key for an already selected manipulator will disable it, leaving only the move manipulator active.
Translation manipulator
The translation manipulator has handles that can be targeted and dragged to translate the selection along the x, y, and z axes (oriented relative to the pivot). It also has shortcut keys, holding left shift and using the directional keys will translate the selection in unit steps.
Since the last dev diary video, I’ve also implemented code to align the selection while using this manipulator. To do this it uses a BoxCollider, again taking the selected pivot point group for size, and positions it relative to the pivot point. It then detects collision contacts against the collider with frozen parts, to find any directly adjacent ones to align the selection to.
Rotation manipulator
The rotation manipulator also has draggable handles, in this case to rotate the selection around the x, y, and z axes. Again, it has shortcut keys, left shift and the directional keys will rotate the selection in 90 degree steps. It will also now align the selection while rotating it, in the same way as the translation manipulator.
Resize manipulator
A long standing request from some players has been to make part resizing easier and more intuitive. The resize manipulator is now there to achieve this, it provides draggable handles to resize the selected part. Just like the other manipulators it also has shortcut keys, left shift and the directional keys will resize the part in the available resizing directions.
This manipulator is only available for use if a single part is currently selected (and that part is resizable of course). Resizing multiple parts together is not possible, although I may revisit this in the future.
Summing up
OK, that’s about it for this update! Sorry it was a long one, despite skimming over a lot of details.
There’s still a lot more I want to do to further improve the building controls, and extend their functionality, but I think I now have a solid basis to work from. The most important thing now is to implement some tutorials to introduce new players to building in GearBlocks, so that’s what I’ll be working on soon.