We have made numerous changes to reduce the entire asset difficulty and the amount of time required for turret parts swapping by introducing the modular approach. Much of this system happens automatically. And if you’re going to add new parts why not do it in style?
Let’s check out one of the most useful tools on the list: the Turret Editor window. It’s in the Forge3D menu located in the upper center of your screen.
It will take you to a new window dedicated to turret assembly and general setup. This is where things start to get interesting.
The first and the leftmost column lets you create, manage and keep turret templates, which are shared across the entire project in a ScriptableObject database.
Name – This returns a template name you can modify
Add to a scene – One can create a new turret instance in the scene from a particular template. It will also position new turret transformation regarding the current selection in the hierarchy.
Add – This adds an empty turret template into database
Duplicate – One can create a duplicate for any template by selecting an existing template and clicking ‘Duplicate’.
Remove – This option deletes a selected template from the database. Please note, removing a template will unlink all the relevant turrets in the scene.
Templates – This lists all the Turret templates available in the ScriptableObject database. Selecting any item from the list will update the Turret setup column. You can also delete a template by clicking the ‘X’ button next to an element in the list.
Once the new turret template is confirmed, the editor will pick up all the available parts, and the user can then use them to build the turret.
When the user makes a change such as swapping parts or toggling a checkbox, the Turret Constructor component starts the reconstruction process immediately.
The general technique is the same for any platform with one exception: the mobile platforms should be limited to LOD1 prefabs only, and the LODGroup checkbox should be disabled.
From the perspective of the modular asset, the easiest way to take care of dynamic editing of the content was establishing an entirely covered rig with interchangeable parts. With that in mind, we introduced the unified skeleton with a few requirements so that a turret section requires a special socket to plug in.
The frame is based on a parent game object with various parts distributed across the turret rack. Depending on a role in the rig, certain parts require a socket in its prefab.
The socket defines an attachment point describing how the parts stack together. Further customization is possible by nesting multiple sockets within a prefab.
Depending on the part, a particular type of socket is required to determine the component group it belongs to:
Socket search options define a strict pattern in finding a socket object within a prefab. For example, the existing socket name can be described such as:
*SOCKET_ Visual identifier of a socket object in the hierarchy
#GROUP# Component group this particular socket belongs to
#NAME# Unique socket name
In addition to that, the socket name can be fully customized
The last rightmost section of the editor is where you can add new turret parts and modify socket names.
That’s all it takes. But before we can make anything move, we need to unlink the new turret from the editor. We’re going to select the turret in the scene and check out the Turret Constructor component.
One of the greatest thing about Turrets is the ability to sculpt any turret design no matter what type you’re trying to build. In the very same way, we also allowed the automatic parts assembly on a turret skeleton using the utility component.
The concept is simple. Turret Constructor ensures a turret is always updated with the latest changes and once the template is confirmed, the parts of the turret skeleton are replaced in the process. The Turret Constructor component is added automatically upon building up a turret.
In addition to that, a particular turret can also be toggled between the templates using a popup.
The key thing to remember is that a Turret Constructor will overwrite any user changes through a skeleton reconstruction during the editor updates.
Now that we’ve looked at how to setup a turret from scratch, we’ll now disconnect our instance from the Turret editor to prevent any further changes to its state.
You can unlink a turret by clicking ‘Unlink from turret template’ button located at the very bottom of a Turret Constructor.
That’s it! When you’re happy with the changes, you can now create a new prefab and toss it into the action!