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

  1. Create an Empty Object in Unity. Add the following:

Rigidbody

Field

Value

Field

Value

Use Gravity

false

Is Kinematic

true

Stationary Cube

  1. Add a 3D cube as a child of Slide Remove Example. Add or configure the following:

Rigidbody

Field

Value

Field

Value

Use Gravity

false

Is Kinematic

true

Box Collider

Field

Value

Field

Value

Is Trigger

true

Sliding Joint

  1. Create an Empty Object as a child of Stationary Cube

  2. Right click on the Sliding Joint Object

  3. Select: Motive > Joints > Add Sliding Joint

This will add a Rigidbody and a Sliding Joint. Configure them this way:

Rigidbody

Field

Value

Field

Value

Use Gravity

false

Is Kinematic

false

Sliding Joint

Field

Value

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.

  1. Right click on the Sliding Joint Object

  2. Select: Motive > Make Attach Receiver. This will add a VR Attachable Receiver.

VR Attachable Receiver - Colliders

Field

Value

Field

Value

Size

1

Element0

Stationary Cube

  1. (Optional) Add a Joint Effects component:

Joint Effects - Upper Limit Reached

Field

Value

Field

Value

Haptic Effect

Bump

Slide Removable Part

  1. Create an Empty Object as a child of Sliding Joint

  2. Right click on it and select: Motive → Make Attach Receiver. This will add a VR Grabbable and a VR Attachable.

  3. Delete the Box Collider. It is not needed.

VR Grabbable

Field

Value

Field

Value

Track Orientation

false

VR Attachable - Attached Grab Settings

Field

Value

Field

Value

Release Behaviour

Leave in Place

Move Mode

Physics

VR Attachable - Detached Grab Settings

Field

Value

Field

Value

Release Behaviour

Return

Move Mode

Kinematic

VR Attachable

Field

Value

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

Field

Value

Size

1

Element0

Sliding Cube

 

  1. Right click on it and select: Motive → Joints → Add Fixed Joint. This will add a Fixed Joint:

Fixed Joint

Field

Value

Field

Value

Connected Rigidbody

Sliding Joint

Sliding Cube

  1. Add a 3D Cube as a child of Slide Removable Part

  2. Reduce the size of the Cube so it is smaller than the Stationary Cube

  3. 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

Related Articles