Slide to Remove
In depth learning on Scene Configuration can be found in this course in Motive Academy.
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.
Â
Overview
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
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
Select: Motive > Make Attach Receiver. This will add a VR Attachable Receiver.
VR Attachable Receiver - Colliders
Field | Value |
---|---|
Size | 1 |
Element0 | Stationary Cube |
(Optional) Add a Joint Effects component:
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 |
Â
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
Reduce the size of the Cube so it is smaller than the Stationary Cube
In the Scene, position the Sliding Cube on top of the Stationary Cube
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