Basic Tutorial - Wrench
To get started, first download the Tutorial Project
This is what you will learn to make in this tutorial
Project goal
The goal of this basic tutorial is to assemble a wrench and rig it with a kinematic setup.
Create a Kinematic Controller.
Add a Wheel Joint to the Screw.
Add a Prismatic Joint to the Jaw.
Create a kinematic relation between the Screw and the Jaw.
Project overview
The project consists of a predesigned model that has been optimized and correctly put into the Hierarchy. Textual reference has been added to each of the steps, please find these under the Wrench Tutorial. The textual reference is displayed in the Inspector.
You can find the correct scene in the Tutorial Project under
Assets > 1 - Basic Tutorials > 1 - Wrench Tutorial > 1 - Exercise - Wrench Tutorial
3d-model of the wrench (included with the tutorial)
Hierarchy setup
For reference, the finished setup has also been provided. Open the scene: 1 - Finished - Wrench Tutorial under Assets > 1 - Basic Tutorials > 1 - Wrench Tutorial
Step 1. Create a Kinematic Controller
If you want to use Kinematics, you will firstly need a V2020.1.56.3_ Kinematics Controller . This component controls all Kinematic Transforms in the scene.
To create a Kinematics Controller, go to Mechanics > Add Kinematics
The Kinematics Controller will be automatically assigned to the selected GameObject, or when there is no GameObject selected, a new one will be automatically created.
For now, deselect everything and add a Kinematics Controller.
Make sure to place the Kinematic Controller above the parts you want to control, in this case the Wrench. Drag the Wrench onto the NEW_KINEMATICSCONTROLLER.
Step 2. Add a Wheel Joint to the Screw.
To create a V2020.1.56.3_ Wheel Joint and assign it to a GameObject, select the GameObject and go to Mechanics > Add Kinematics > Wheel Joint. Add it to the Screw GameObject.
The Wheel Joint is created with a standard radius of 1 unit, we will change this to 0.1. Select the Screw and got to the Inspector. Under Wheel Joint, change Wheel Radius to 0.1
This will create a Wheel Joint attached to the Screw. Make sure your Gizmos are turned on, so will you see the newly created Wheel Joint. To turn on Gizmos, go to the top-right of the Scene View, and press Gizmos.
The Wheel Joint is currently not aligned to the Screw, to change this go to Wheel Axis Direction and change the Vector Space to Local Child and the Vector to Forward.
Turn on Enforce Outside Playmode, and under Wheel Joint State change the value of Current Rotation State to see the Screw rotate.
Step 3. Add a Prismatic Joint to the Jaw.
To create a V2020.1.56.3_ Prismatic Joint and assign it to a GameObject, select the GameObject and go to Mechanics > Add Kinematics > Prismatic Joint. In this case, select the Jaw and add a Prismatic Joint.
A Prismatic Joint needs a SplineUNDEFINED to be able to function. To create a Spline, go to Utilities > Create > Spline.
The NEW_SPLINE will be created with two control Points.
We are going to use the Spline to control and limit the range of motion of the Jaw. The range of the Jaw can be found by looking at the Handle and hiding all other GameObjects.
To align a Point to the Wrench, drag it to the right position. Hold down V to snap to vertices and position the point perfectly. Turn on Wireframe Shading to get a better look.
Align the Spline to these points.
Make sure the NEW_SPLINE is parented under the Handle GameObject.
First, position the Jaw to be closed. The Pivot Point of the Jaw is located at the top, and because the Prismatic Joint will align the Jaw according to its Pivot, we have to make sure the starting position corresponds with the Spline.
Select the Jaw and under the Prismatic Joint in the Inspector, go to Limit Relation & Update Settings. Select the NEW_SPLINE.
To check the correct range of motion of the Jaw, turn on Enforce Outside Playmode and move the Jaw.
The Jaw now moves too far down, this is not realistic. To fix this, we have to adjust the Points of the Spline.
Make sure to turn off Enforce Outside Playmode.
Drag the Jaw to where the bottom position should be. Go to Limit Fine Tuning and select Point[2] at Target Control Point. Then press Update Limit Control Point.
Turn on Enforce Outside Playmode and check the movement of the Jaw again. This looks much better.
Step 4. Create a kinematic relation between the Screw and the Jaw.
To create a Kinematic Chaining between Kinematic Relations, go to the Screw. Under Kinematic Chaining > Trailing Transforms, press Create new Trailing Transform Relation.
Under Opposing Relation Instance, choose the Jaw. Leave Relation Direction set to BIDIRECTIONAL and Relation Type to TRANSLATION.
Now rotate the Screw in the Sceneview to move the Jaw up and down. Alternatively, you can move the Jaw up and down to rotate the Screw.
The amount of rotations the Screw makes is not in relation to it’s actual model, we need to change this.
Adjust the Wheel Radius of the Screw to increase the amount of rotations the screw makes. Change the Wheel Radius to 0.0008.
Prespective Documentation