Create an object that is attached to another object and needs to be slid before it can be removed. This example describes how to create a cube which sits on top of another cube. When slid to a specific point, it can be removed.
The object hierarchy will look like this:
Slide Remove Example
Create an empty object in Unity. Add the following:
Rigidbody
Field | Value |
---|---|
Use Gravity | false |
Is Kinematic | true |
Stationary Cube
Add a 3D cube as a child of Slide Remove Example. Add or configure the following:
Rigidbody
Field | Value |
---|---|
Use Gravity | false |
Is Kinematic | true |
Box Collider
Field | Value |
---|---|
Is Trigger | true |
Sliding Joint
Create an empty object as a child of Stationary Cube.
Right click on the Sliding Joint object and select: Motive → Joints → Add Sliding Joint
This will add a Rigidbody and a Sliding Joint. Configure them this way
Rigidbody
Field | Value |
---|---|
Use Gravity | false |
Is Kinematic | false |
Sliding Joint
Field | Value |
---|---|
Axis | (0,0,-1) |
Connected Rigidbody | Slide Remove Example |
Limit Motion | true |
Upper Limit | 0.1 |
Upper Limit: In Limit | Slide Removable Part; VRAttachable.SetDetachable() |
*You will need to come back to this section at a later point to set the Upper Limit: In Limit value. The object, Slide Removable Part, has not been created at this point. It will be the child of the Sliding Joint object.
Right click on the Sliding Joint object and select: Motive → Make Attach Receiver. This will add a VR Attachable Receiver.
VR Attachable Receiver - Colliders
Field | Value |
---|---|
Size | 1 |
Element0 | Stationary Cube |
Add a Joint Effects component (optional).
Joint Effects - Upper Limit Reached
Field | Value |
---|---|
Haptic Effect | Bump |
Slide Removable Part
Create an empty object as a child of Sliding Joint. Right click on it and select: Motive → Make Attach Receiver. This will add a VR Grabbable and a VR Attachable.
Delete the Box Collider. It is not needed.
VR Grabbable
Field | Value |
---|---|
Track Orientation | false |
VR Attachable - Attached Grab Settings
Field | Value |
---|---|
Release Behaviour | Leave in Place |
Move Mode | Physics |
VR Attachable - Detached Grab Settings
Field | Value |
---|---|
Release Behaviour | Return |
Move Mode | Kinematic |
VR Attachable
Field | Value |
---|---|
Attached To | None |
Requires Detachable | true |
Joint | Slide Removable Part |
*Joint will populate automatically when the Fixed Joint is added. This step will happen later.
VR Attachable - Guide Meshes
Field | Value |
---|---|
Size | 1 |
Element0 | Sliding Cube |
*Sliding Cube will be created later and will need be added here after that is complete.
Right click on it and select: Motive → Joints → Add Fixed Joint. This will add a Fixed Joint.
Fixed Joint
Field | Value |
---|---|
Connected Rigidbody | Sliding Joint |
Sliding Cube
Add a 3D cube as a child of Slide Removable Part. No configuration necessary.
Items to Check
Some steps need to happen after the required objects are created. Double check these settings:
Sliding Joint
Upper Limit : In Limit
Slide Removable Part
VR Attachable - Joint
VR Attachable - Guide Meshes