GearBlocks Demo 0.7.7969
Author: danger726,
published 3 years ago,
Hi everyone, I've now updated the demo main branch with all the builder tool changes from the past several months, so I thought it would be a good idea to summarise everything here.
[b]Part multi-selection[/b]
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, [b]left clicking[/b] on a part selects only that part (not the whole construction). To move the selection around the [b]left mouse button[/b] 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 [b]right mouse button[/b] 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 [b]left control[/b] and [b]left clicking[/b] 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 [b]left control[/b] and pressing [b]A[/b] while targeting a construction provides an easy way to do this.
Finally, [b]left clicking[/b] 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 [b]blue[/b], selected parts in [b]orange[/b], and the targeted part in [b]white[/b]. An example of this can be seen here:
[img]https://clan.cloudflare.steamstatic.com/images//37970304/a201595b0169b2cb5b05cba6016656b7259e6c1b.jpg[/img]
[b]Move manipulator[/b]
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 [i]move manipulator[/i], 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.
[img]https://clan.cloudflare.steamstatic.com/images//37970304/b58c63cf405d7acf885706f62a55f3517c4546fe.jpg[/img]
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 [b]left clicking[/b] 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 [b]left shift[/b] and moving the mouse translates the pivot point (moving the selection under the crosshair). Holding down [b]left shift[/b] and using the [b]directional keys[/b] (e.g. WASD) will rotate the selection in 90 degree steps. Holding down [b]left control[/b] and using the [b]directional keys[/b] will resize the selected part (if applicable).
These shortcuts are mostly the same as with the original building controls, even holding the [b]right mouse button[/b] to rotate the selection with the mouse still works, for those who are used to the old way.
[b]Recap of the builder tool controls[/b]
Selecting parts:-
[list]
[*][b]LMB[/b] to select the targeted part (and deselect all others).
[*][b]Left control + LMB[/b] to add or remove the targeted part from the selection.
[*][b]Left control + A[/b] to select all parts of the targeted construction (and deselect all others).
[*][b]LMB[/b] while not targeting any parts to deselect all.
[/list]Moving the selection:-
[list]
[*][b]LMB[/b] on a selected part (or hold [b]LMB[/b] and drag on any part) to:-
[list]
[*]1) Select the targeted pivot point.
[*]2) Show the move manipulator.
[*]3) Detach the selection from any unselected parts in the rest of the construction.
[/list][*]Hold [b]LMB[/b] and drag the move manipulator handle to move the entire selection, align it to other frozen parts, and so on.
[*][b]LMB[/b] while not targeting a selected part to:-
[list]
[*]1) Attach the selection to any other parts it's being aligned to.
[*]2) Hide the manipulator.
[*]3) Deselect the pivot point.
[/list][/list]Shortcuts while dragging the move manipulator handle:-
[list]
[*]Hold [b]left shift[/b] and move the mouse to translate the selection under the crosshair.
[*]Hold [b]left shift[/b] and use the [b]directional keys[/b] to rotate the selection in 90 degree steps.
[*]Hold [b]left control[/b] and use the [b]directional keys[/b] to resize the selected part.
[*]Hold [b]RMB[/b] (or [b]left shift + RMB[/b]) for legacy mouse rotation.
[*][b]Mouse wheel[/b] (or hold [b]left alt[/b] and use mouse) to "dolly" the selection.
[/list]Other:-
[list]
[*]Hold [b]RMB[/b] to delete the targeted part.
[*][b]Left control + D[/b] to duplicate the targeted part.
[*][b]Left control + F[/b] to freeze / unfreeze the targeted part.
[/list]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.
[b]Alignment targeting[/b]
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 [b]Raycast[/b] would be fired forward from the player's viewpoint to find the part. Instead now, it uses a [b]BoxCast[/b] (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.
[img]https://clan.cloudflare.steamstatic.com/images//37970304/15422e144881b66be111335b44d4f5f19194ec73.jpg[/img]
In some cases however, the more precise [b]Raycast[/b] method is still preferable. For example, inserting a beam in between two other beams is hard to do with a [b]BoxCast[/b], because the selection will tend to align to the outside of one of the beams, as shown here.
[img]https://clan.cloudflare.steamstatic.com/images//37970304/e45e5e16a383087cf4c0e1c7a317c187575052b8.jpg[/img]
So the final solution I came up with was a combination of both methods. First a [b]Raycast[/b] is tried, and then if that doesn't find a part to align to, the [b]BoxCast[/b] 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.
[img]https://clan.cloudflare.steamstatic.com/images//37970304/63e3888764b2e9ea65ddda7d75882fe661f80cb3.jpg[/img]
[b]The other manipulators[/b]
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 [b]R[/b], [b]T[/b], and [b]Y[/b] keys respectively. Pressing the key for an already selected manipulator will disable it, leaving only the move manipulator active.
[i]Translation manipulator[/i]
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 [b]left shift[/b] and using the [b]directional keys[/b] will translate the selection in unit steps.
[img]https://clan.cloudflare.steamstatic.com/images//37970304/0c865e2fa7129b9ca3369bdaca32a8d956435d06.jpg[/img]
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 [b]BoxCollider[/b], 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.
[i]Rotation manipulator[/i]
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, [b]left shift[/b] and the [b]directional[/b] 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.
[img]https://clan.cloudflare.steamstatic.com/images//37970304/a9149aa6a220284a25f1e52921e51bd03f1367e7.jpg[/img]
[i]Resize manipulator[/i]
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, [b]left shift[/b] and the [b]directional keys[/b] will resize the part in the available resizing directions.
[img]https://clan.cloudflare.steamstatic.com/images//37970304/d2df69ea55fa405af41f8c0485d4faa8194dee17.jpg[/img]
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.
[b]Summing up[/b]
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 players to building in GearBlocks, so that's what I'll be working on soon.