Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Panel
panelIconId1f393
panelIcon:mortar_board:
panelIconText🎓
bgColor#4C9AFF

Table of Contents
minLevel1
maxLevel6
outlinefalse
typelist
printablefalse

Overview

This article describes how to take a bottle with a cap attached. And, make it so both the cap and the bottle can be grabbed and moved around separately then reattached. The bottle and the cap will also be using gravity physics.

We will do this using four premade Motive SDK features.:

  • VR Attachable

  • VR Attachable Receiver

  • VR Grabbable

  • Fixed Joint

...

Setup

For this example, we are starting with this relatively simple bottle and bottle cap prefab variant:

...

    ...

    1. Right-click on the bottle in the Hierarchy window

    ...

    1. Select Motive > Make Grabbable

    ...

    1. Right-click on the bottle again

    ...

    1. Select Motive > Make Attach Receiver

    ...

    1. Expand the bottle in the Hierarchy window and right-click on the bottle cap

    ...

    1. Select Motive > Make Grabbable

    ...

    1. Back on the bottle cap, right-click and select Motive > Joints > Add Fixed Joint

    ...

    1. On the bottle cap, right-click and select Motive > Make Attachable

    2. Finally, in the Inspector for the bottle cap, scroll to the bottom and select Add Component

    ...

    1. Type in Mesh Collider

    2. Select Mesh Collider when it appears

    Info

    NOTE: If there is already a Mesh Collider on the cap, there is no need to add a second

    Configuration

    ...

    All the necessary components have been added. Now we will add grab anchors for both the cap as well as the bottle itself.

    1. Right-click on the bottle in the Hierarchy

    ...

    1. Select Create Empty

    ...

    1. Modify the Y Position value under the Transform component of the new empty object (Move it near the middle of the bottle lengthwise)

    ...

    1. Select the bottle and then open the VR Grabbable

    ...

    1. Drag your new empty object into the black box next to Grab Anchor that reads “None (Transform)”

    ...

    1. Do the same thing for the cap of the bottle. Right-click on the cap and select Create Empty again

    ...

    1. Modify the new empty objects Y Position value under Transforms so that it is somewhere near the center of the bottle cap

    ...

    1. Select the cap and once again, under VR Grabbable, drag the new empty object into the same Grab Anchor box

    Now, we must configure all of the newly attached components to replicate the behaviours shown in the video above.

    ...

    1. Select the bottle

    ...

    1. in the Hierarchy

    ...

    1. Expand the Rigidbody component and make sure that Use Gravity and Is Kinematic are toggled to on

    2. Expand the VR Attacahable Receiver and select the

    ...

    1. “Target”icon featured on the box next to Joint; the box should read “None (Base Joint).

    2. Once the new window opens, select the cap joint

    3. Expand the VR Grabbable component

    4. Set Snap Position to Always

    5. Set Snape Orientation to Always

    ...

    1. Select the cap

    ...

    1. in the Hierarchy

    ...

    1. Expand the Box Collider and set Is Trigger to On

    2. Expand the Rigidbody

    3. Toggle Use Gravity to On

    4. Toggle Is Kinematic to Off

    5. Expand the Mesh Collider and set Convex to On

    6. Expand the VR Attachable

    ...

    1. Expand Attached Grab Settings

    2. Toggle Working Surfaces Only to On

    3. Set Release Behaviour to Use Physics

    ...

    1. Expand Detached Grab Settings

    2. Toggle Working Surfaces Only to On

    3. Set Release Behaviour to Use Physics

    4. Select the

    ...

    1. “Target”icon featured on the box next to Attached To; the box should read “None (Base Joint).

    ...

    1. Select the bottle receiver

    2. Expand the VR Grabbable

    3. Toggle Allow Distance Grab to On

    ...

    1. Take your prefab variant and drop it into a VR scene

    ...

    You should be able to use the bottle and cap the same way highlighted in the above video.

    Troubleshooting

    • If you are concerned about the release behaviour of your cap. Remember that the release behaviours you define in VR Grabbable will always be overwritten in VR Attachable.

      • However, not all values set in VR Grabbable are mutual between itself and VR Attachable.

    • If the bottle and cap behaviour is not what you see in the video, be sure to double-check your component configurations. Specific changes to other components can affect one another.

    • If you see that specific configurations change during runtime during playtime, do not be alarmed. For example, values like Collision Detection, Use Gravity, etc., will all change when an object is dropped, grabbed, etc.

    • Do not treat Mesh Colliders and Box Colliders the same. For example, if you set Is Trigger to On in your mesh collider instead of the Box Collider on the bottle cap, the cap can be reattached but not nearly as fluidly.

    • Feel free to ignore prompts similar to these found at the top of VR Grabbable and Fixed Joint components. They are redundant.

    ...

    Related Articles

    Recipes